473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

c# : asp.net : problem wit session and server.transfer

i have

void Application_Error(object sender, EventArgs e)
{
Server.Transfer("default.aspx");
}
in global.asax

now when i use any state bags like Session["sno"] = "new";
whenever the user clicks on link to a page that does not exist on the server, Application_Error() executes but Server.Transfer does not and it shows that the page cannot be found and does not transfer to default.aspx.
why is Server.Transfer not getting executed ??
Jan 6 '08 #1
5 2591
kunal pawar
297 100+
rather than to use server.transfer

add following code in ur web.config

<customErrors defaultRedirect="default.aspx" mode="On">
</customErrors>
Jan 7 '08 #2
this wont work as i have to display the url that the user has clicked
i.e http://localhost:1126/N/default5.aspx

but customerror displays
http://localhost:1126/N/default.aspx.../default5.aspx
in the address bar

is there some other way to do this??
Jan 7 '08 #3
kenobewan
4,871 Expert 4TB
I think that you may benefit from this overview:
How to create custom error reporting pages in ASP.NET by using Visual C# .NET

I'm not sure what you are hoping to achieve, an application error is unlikely to display the default page (hence the need for error handling).
Jan 7 '08 #4
i am sry but the above link doesnt slove my problem

i have a link on my page which points to default5.aspx
but as default5.aspx does not exist on the server the Application_Error is invoked :
void Application_Error(object sender, EventArgs e)
{
Server.Transfer("default.aspx");
}
which tansfers the user to default.aspx but shows default5.aspx in the address bar.
now if i use state bags like Session["sno"] = "new"; itshows the error that default.aspx is not found on the server.

if use customerrors in web.config then it does redirect to default.aspx but shows some asp error url in the address bar.
but i want to display default5.aspx in the address bar
but how??
Jan 7 '08 #5
Frinavale
9,735 Expert Mod 8TB
i am sry but the above link doesnt slove my problem

i have a link on my page which points to default5.aspx
but as default5.aspx does not exist on the server the Application_Error is invoked :
void Application_Error(object sender, EventArgs e)
{
Server.Transfer("default.aspx");
}
which tansfers the user to default.aspx but shows default5.aspx in the address bar.
now if i use state bags like Session["sno"] = "new"; itshows the error that default.aspx is not found on the server.

if use customerrors in web.config then it does redirect to default.aspx but shows some asp error url in the address bar.
but i want to display default5.aspx in the address bar
but how??
When you use Server.Transfer the requested URL is displayed in the browser.
The reason is because the Server changes what ASPX page to display....

For example:
The user requests the requestedAspxPage.aspx :
The requestedAspxPage.aspx doesn't exist, so you call Server.Transfer(anotherAspxPage.aspx)
The Server uses anotherAspxPage.aspx instead of the requestedAspxPage.aspx.

Since the server handles this, the URL in the web browser is not changed.

Now, if you use Response.Redirect(anotherAspxPage.aspx), the server returns an HTML code indicating to the browser that it should request anotherAspxPage. The URL is changed and the browser requests the "anotherAspxPage" instead of the requestedAspxPage.

I would use Response.Redirect for "Page Not Found" (404) errors...because if the url still points to a page that doesn't exist, the next time the user does a postback another error will occur again.

You can Rewrite the URL if you want...
See URL rewriting in ASP.NET for more information on the topic.

-Frinny
Jan 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
3
by: Siobhan | last post by:
I am getting the following error: Run-time exception thrown : System.Web.HttpException - Session state can only be used when enableSessionState is set to true, either in a configuration file or in...
2
by: David Berman | last post by:
It seems that my site is losing session information when using Server.Transfer. I have a page called PictureGallery.aspx. It takes an argument which is an index id, so it would look like...
2
by: PJ | last post by:
I'm trying to set up a front controller pattern in my web application but having Session issues when using Server.Transfer. I have created a web handler that processes requests for .ptv files. I...
0
by: themattconnolly | last post by:
I have an application built on virtual pages, where the url is intercepted and a different page is built according to the url. In order to also use forms authentication, I had a Server.Transfer...
10
by: GreggTB | last post by:
I've got an page (LOGIN.ASPX) that receives the user's login information. During the page load, it checks the credentials against a database and, if validation is successful, creates an instance of...
9
by: cashdeskmac | last post by:
I have put a string into Session and tried to retrieve it on the next page I visit but the Session appears empty. I have exactly the same spelling for both adding and retrieving the value: ...
5
by: Terry On Windigo | last post by:
I think I have figured out my problem but I don't know how to solve it. We are going to start using a forums package and do not want our users to have to login to both our site, and then again to...
2
by: Fernando Rodriguez | last post by:
I created an HttpHandler for rewritting URLs. It simply checks if the requested page is on a list of "special" pages (that do not exist) and if it is on the list then it will transfer to an ASPX...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.