Category Archives: ASP.NET

Using IECapt.exe with IIS, ASP.net

asp.net

I used IECapt to generate screenshots of user websites, to display in their control panel.
Being a front-end dev, I don’t normally call a processes and envoke applications, but I was able to find some code to help me along. Unfortuatelty, I ran into some issues with permission when trying to execute the exe.

While developing on my local machice, I had no trouble generating screenshots with the following sample code.

public static void GenerateScreenShot(string url, string fileout){
            Process myProcess = new Process();  
            myProcess.EnableRaisingEvents = false ;  
            myProcess.StartInfo.RedirectStandardOutput = false;
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.FileName = @"" + System.Web.Configuration.WebConfigurationManager.AppSettings["IECaptPath"].ToString();
            myProcess.StartInfo.Arguments = @"--url=" + url + " --out=" + fileout + " --min-width=1200";
            myProcess.Start();  
            myProcess.WaitForExit();  
            myProcess.Dispose();
}

Unfortunately when deploying on IIS it encountered “Access is Denied” errors when trying to execute the exe. This mostly is because the IIS USER does not have permission to execute the file. Even though I tried to give it permission, it would not work.

After examining other code that uses Process(), I removed “EnableRaisingEvents”, “RedirectStandardOutput” and “UseShellExecute” and it finally worked!

public static void GenerateScreenShot(string url, string fileout){
            Process myProcess = new Process();  
            myProcess.StartInfo.FileName =  @"" + System.Web.Configuration.WebConfigurationManager.AppSettings["IECaptPath"].ToString();
            myProcess.StartInfo.Arguments = @"--url=" + url + " --out=" + fileout + " --min-width=1200";             
            myProcess.Start();  
            myProcess.WaitForExit();  
            myProcess.Dispose();
}

Control Stretching Textboxes, Beyond 100%

asp.net

In ASP.NET I have created a form inside of a fixed width table, and added css to make my textboxes 100% width. For some reason, a long value assigned on the server side was stretching my textbox way past the the defined width of the table cell.

Initial Code:

Title

Solution:
Wrap the textbox inside a div with relative position, then give the textbox an absolution position.

Title