473,795 Members | 3,151 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

47 New Member
i have

void Application_Err or(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_Err or() 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 2616
kunal pawar
297 Contributor
rather than to use server.transfer

add following code in ur web.config

<customErrors defaultRedirect ="default.as px" mode="On">
</customErrors>
Jan 7 '08 #2
vishalgupta
47 New Member
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 Recognized Expert Specialist
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
vishalgupta
47 New Member
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_Err or is invoked :
void Application_Err or(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 Recognized Expert Moderator Expert
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_Err or is invoked :
void Application_Err or(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 requestedAspxPa ge.aspx :
The requestedAspxPa ge.aspx doesn't exist, so you call Server.Transfer (anotherAspxPag e.aspx)
The Server uses anotherAspxPage .aspx instead of the requestedAspxPa ge.aspx.

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

Now, if you use Response.Redire ct(anotherAspxP age.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 "anotherAspxPag e" instead of the requestedAspxPa ge.

I would use Response.Redire ct for "Page Not Found" (404) errors...becaus e 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
3241
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 go to is a login form, which will set several session variables with the name used to log in, appropriate security level and some other misc variables, and then will go to a main menu for each particular security level using Server.Transfer. ...
9
2386
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 - perhaps I'm just not very smart or perhaps MS is making this too hard for us sql bunnies to understand - I dunno, but I'd really appreciate someone explaining what I'm doing wrong here & perhaps suggest a better approach.. I'm familiar with use of...
3
2493
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 the Page directive Session state is enabled throughout the application. This is occuring after I do a server.transfer and I am passing details between my 2 pages using Context.Items collection. It would appear theuse of the Context.Items...
2
3762
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 PictureGallery.aspx?id=30 to display gallery 30. In this way I have a database driven picture gallery. To improve indexing, I put code in Global.asax to allow me to get to the same page with a url like this: Pictures_30.aspx. There is no...
2
1935
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 have enabled default documents for the web app and set the top entry to default.ptv and have created blank files in all of the directories named default.ptv. The client initially requests a page with a url like www.domain.com/admin/ and the...
0
1941
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 call in a custom HttpModule, called by AuthenticateRequest. The problem is that now I want to access session variables that are set on the application's start, but calling Server.Transfer inside of AuthenticateRequest loses reference to the session....
10
12212
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 an object that stores the user's basic profile data (username, user type, associated sales region, etc.). I've been taking this user info and placing it in the Session object like so... Session = user;
9
2217
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: Session = "john"; On the next page: txtName.Text = Session;
5
1687
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 the forums package. The creator of the forums package provides what seems to be an easy workaround for this. Create two session variables, one for ID, the other for Password, and his program will take care of the rest. I have all of my forums...
2
3042
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 page that will generate the content dynamically. The problem is that after the call to Server.Transfer or Server.Execute the page i'm transfering to throws an exception when it tries to access the Session object. The error says that I must set...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10438
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.