Querystring

J

Jose

Hi All,

I want to ensure that a querystring parameter is included for every
request (TabID). If this parameter does not exist I want to redirect
the use to the default url (/Default.aspx?TabID=1). Previously, in
ASP.Net 1.1 I processed this within the BeginRequest event in
Global.asax.cs. I am now using ASP.Net 2.0 so I was wanting some advice
how best to achieve this - do I need to write a httphandler or
something? Any help is most appreciated.

Kind regards,
Jose
 
V

Vadivel Kumar

In a simpler way, checking the Page.QueryString.Count will give you
whether any query string passed with url or not. So, based on this you
can go ahead and check the passed TabId or redirect to default page.

The same thing may be kept in BeginRequest event. It doesn't matters
where you keeping this code. Both will do same work.
 
G

Guest

Why would you want to do this? If you want to persist some value accross the
session then save it in a session variable? Users can manipulate the
querystring.
 
G

Guest

Jose,
This can be done in a single line of code in the Page_Load handler:

if(Request.QueryString["TabId"]==null) Response.Redirect("Yourpagehere.aspx");

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top