Sys.WebForms.PageRequestManagerTimeoutException - The server request timed out - error

by rezashirazi 1/8/2009 8:17:00 AM

Last week I had a problem when I tried to export an image from the AGS 9.2 to a pdf file. I got this error: “Sys.WebForms.PageRequestManagerTimeoutException The server request timed out” from the Ajax Extension framework. Its occurred because the export operation was relatively long (something like 2 minutes) and the Ajax Extension Callback framework had a timeout.

 

How to solve this problem?
To solve this problem we can increase the timeout. You can change the timeout time by adding a new property to the script manager control. This property is called AsyncPostBackTimeOut and it can help us to define the number of seconds before the request will throw a request timeout exception*.

For example if you want that the timeout will take maximum 10 minutes your code should be look like this:

 

<asp:ScriptManager ID=”ScriptManager1″ runat=”server”

AsyncPostBackTimeOut=”600″ >

</asp:ScriptManager>     

* The default value of the AsyncPostBackTimeOut property is 90 seconds.

Currently rated 3.2 by 6 people

  • Currently 3.166667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

ASP.NET

Cookies and Unicode characters

by rezashirazi 12/20/2008 2:21:00 PM

I’ve been having some issues with storing Unicode characters in cookies today. Whenever a cookie is set and the value filled with Unicode characters, the same characters cannot be retrieved from the cookie again. When they are retrieved from the requesting browser, they are changed into something totally unreadable.

Background

The cookie is set when a visitor enters some text into a textbox and submits the form. When the same visitor returns to that page I wanted to pre-fill the textbox with the value submitted earlier. Very easy and simple and not before someone noticed the strange behaviour with Unicode characters I thought it worked just fine.

Because the value was displayed in a textbox I thought that maybe HTML encoding could solve the issue. Don’t ever HTML encode a cookie in ASP.NET! It results in a yellow screen of death and an exception stating that the cookie contains dangerous characters. The dangerous character it was referring to was a HTML encoded representation of a Unicode character and looked something like this "#248;". The only thing to do is to delete your cookies in order to view that page again.

The solution

It took me a while to figure it out, but all you need to do is to URL encode the cookie value. It works no matter what encoding you use for the page. The example below illustrates the very simple solution:

private void SetCookie()
{
  HttpCookie cookie = new HttpCookie("cookiename");
  cookie.Expires = DateTime.Now.AddMonths(24);
  cookie.Values.Add("name", Server.UrlEncode(txtName.Text));
  Response.Cookies.Add(cookie);
}

private void GetCookie()
{
  HttpCookie cookie = Request.Cookies["cookiename"];
  if (cookie != null)
  {
    txtName.Text = Server.UrlDecode(cookie.Values["name"]);
  }
}

It is so simple but caused me a lot of time investigating and clearing cookies from the browser.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

ASP.NET

Server was unable to process request. ---> Unable to generate a temporary class (result=1).

by rezashirazi 12/9/2008 8:16:00 AM
When you have created virtual directory of your application created in .Net2.0 and application is not running.
Even everything is fine in web.config, still it is giving error in web.config file.

Error :- The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

Solution is
goto command prompt then navigate to directory

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

Now run this command

aspnet_regiis -ga "NT AUTHORITY\NETWORK SERVICE"

Everything will wok fine.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

ASP.NET | IIS

How to determine asp.net previous page is exist

by rezashirazi 11/24/2008 3:26:00 PM

Hi,

 I found a nice solution for backing to previous page (client side) in asp.net. it is very simple you can write below command in your code behind then the client browser back to previous page client side with javascript back command: 

 response.redirect("javascript:back(1);")

But if the desire page does not have previous page you have to determine if previous page exist or not, like this:

if page.previouspage is nothing then

 response.redirect("~/default.aspx")

else 

  response.redirect("javascript:back(1);")

end if 

 But many times page.previouspage object is null! instead above method you have to use below method :

if request.urlrefferer is nothing then

 response.redirect("~/default.aspx")

else 

  response.redirect("javascript:back(1);")

end if 

 

Happy Programming Smile

Currently rated 2.3 by 3 people

  • Currently 2.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

remove tags from html string function

by rezashirazi 11/15/2008 1:46:00 PM

You can create a function for removing html tags from html string. here it is:

    Protected Function removeHTML(ByVal html As String) As String
        If String.IsNullOrEmpty(html) Then
            Return ""
        Else
            Return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", String.Empty)
        End If
    End Function

 Happy Programming Smile

How to convert Relative URL to Absolute URL in ASP.NET page

by rezashirazi 11/12/2008 3:59:00 PM
Very often we have a relative URL of some page or resource like "~/img/logo.gif" and we need an absolute URL
to insert it in some control or link (something like "http://www.rezashirazi.com/img/logo.gif")

Asp.Net 2.0 has some very useful methods that could help us to resolve the absolute URL we need.

First of them is Page method ResolveUrl() that converts a relative URL into one that is usable on the requesting client.
This means you we can pass to this method an URL that is relative to the current page, something like this:


        Page.ResolveUrl("img/logo.gif");
 

and it would return to us a valid relative URL , taking into account the current URL of the Page from where you are calling it.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

ASP.NET

Increase session timeout of asp.net login control

by rezashirazi 11/10/2008 12:25:00 PM

If you use ASP.NET login control in your website, by default login session of your accounts expired after 20 minutes. For increasing session timeout there are some different methods but the simpleset methos is change your website configuration in web.config file. you have to add below data in your web.config file for this reason:

<sessionState mode ="InProc" timeout="540"/>

<httpRuntime executionTimeout="999999"/>

but If you are using Asp.net login control your session timeout problem exists after these changes. for increasing session timeout of asp.net login control change authentication tag in your web.config to below tag:

<authentication mode="Forms"> <forms timeout="540" slidingExpiration="true" loginUrl="~/Login.aspx" />

</authentication>

Your session expiration time is now 9 hours(540 minutes)! Smile

ASP Net - BC30456: 'Title' is not a member of 'ASP.

by rezashirazi 11/5/2008 5:30:00 PM

Hi All,

I did have an error like BC30456: 'Title' is not a member of 'ASP....

On my application the error was cause by the Inherits tag. Both of my child forms had the same Inherits "_Default". Then I changed one and it is ok now

Note: You have to change the Inherits tag in the .aspx and in the related .vb files because your inherits tag is repeated in other pages.

 Exemple .aspx :
<% @ Page Language ="VB" MasterPageFile="~/site.master" AutoEventWireup ="false" CodeFile="samplepage.aspx.vb" Inherits="_Default2" title="Sample Page" %>

Exemple .vb :
Partial Class _Default2 Inherits System.Web.UI.Page

 

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

ASP.NET

How to send mail using Gmail and ASP.NET

by rezashirazi 10/30/2008 9:35:00 AM
<script runat="server">
    protected string now = DateTime.Now.ToString();
    public void Page_Load(object sender, EventArgs e)
    {
        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("yourid@gmail.com", "yourpassword");

mail.To.Add("a@a.com");
mail.Subject = "subject goes here";

mail.From = new System.Net.Mail.MailAddress(yourid@gmail.com);
mail.IsBodyHtml = true;
mail.Body = "This message has been sent programmatically with GMail";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Send(mail);
    }
</script>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

ASP.NET | C#

How to change the default session timeout in IIS 6.0

by rezashirazi 10/21/2008 4:54:00 PM

Follow the steps below to change the default time session timeout in IIS.

1. Start Internet Information Services (IIS) administration tool (snap-in) from the Control Panel.
2. Navigate to the "Default Web Site" node, right click on it and then select "Properties".
3. In the 'Directory' tab click "Create" button, then click "OK".
4. Click on the "Home Directory" tab, then "Configuration".
5. Click on the "Options" tab.
6. Increase the "Session timeout" value and click "OK" twice until you return to the IIS snap-in.

Currently rated 1.5 by 2 people

  • Currently 1.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

General

About the author

Name of author Reza Shirazi Mofrad
Interests: Image processing, computer vision, Artificial intelligence, Microsoft .NET technologies, Web programming.

E-mail me Send mail

Calendar

<<  July 2009  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Site statistics

Tags

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009

Sign in