Wednesday, July 28, 2010

Page load twice

I know you may have already frustrated of this issue. Even I was really fed up when I came a cross this weird issue. I was facing this issue when I test my web application with Firefox 3.6.6, I did not check with any previous versions (and I found no issues with IE and some other browsers). Believe me it takes a lot of time to cure this. There are many possibilities but mine was a bad CSS practice, you may be wondering how CSS reloads the whole web page.
This was the issue in my CSS code background-image:url(''), having a empty image URL.
I thought reloading the page twice an issue with my coding on page behind, but ultimately it was a CSS issue.

Let me tel me why an empty URL gives such a major issue. Once the page loads the firefox still tries to find the empty URLs so page loads twice but IE just replaces the empty URL with null value.

As I mentioned above this may not the exact cause for your problem but one of the following might cause your issue. Please visit the following URL ( to see more possibilities. Hope this guides you to find the issue.
Monday, July 19, 2010

must be placed inside a form tag with runat=server

I got to explain the scenario I cameacross this issue, as this might vary for some other scenarios. I got this error when I try to override the PreRender event of the masterpage's
Content Holder (idea was to get the html of that area what evel loding in to that).

ContentPlaceHolder cph = (ContentPlaceHolder)Master.Controls[0].FindControl("master_content_holder");
var sb = new StringBuilder();
var sw = new StringWriter(sb);
var htmlTxtWr = new HtmlTextWriter(sw);
SmtpUtil smtpUtil = new SmtpUtil();

I got this error exactly on the last line of code. As error message states our all controlls must be inside a form tag with runat = server (note you can't have form tags on child pages, do not try it, it won't work). I did a small dirty work as to fix this issue.
I just overrided the VerifyRenderingInServerForm mehtod on child page. For me it worked properly, as i didn't have any verification to be done on my page. Be carefull before use.
Thursday, July 15, 2010

Drop emails in a folder

Instead sending an email we can configure the web.config to drop the mail in a local folder.
This is a good feature when it come to testing email on your application while developing.

Just add the following on the web.config

   1:     <>
   2:       <mailSettings>
   3:         <smtp deliveryMethod="SpecifiedPickupDirectory">
   4:        <specifiedPickupDirectory pickupDirectoryLocation="C:\testmails\"/>
   5:         </smtp>            
   6:       </mailSettings>       
   7:      </>

Following code will drop an email in your folder

   1: var smtpClient = new SmtpClient();
   2: var message = new MailMessage("", "");
   3: message.Subject = "This is the mail subject";            
   4: message.Body = "this is the mailm body";
   5: smtpClient.Send(message);         
Double click on the file in your C:\testmails\ folder it will open up on outlook
as an email.

Thursday, July 08, 2010

Take web site offline App_Offline.htm

Do not need to do any setting on ISS, instead just move in an HTMl file named
App_Offline.htm . This will stop responding to any web request but as the response
this file passes until you remove it from the root or rename it.

My Achievements

Member of

Blog Archive