tags:

views:

507

answers:

4

Hi all, I have problem with default.aspx setting in global.asax file.When i am running dot net application from solution explorer i can set the default page as start page or when i am running the application the on IIS server i can set that default page as start page through the setting.This thing i want to do in programmatic way using the global.asax file and session start method.Without doing any setting whenever i will run the application the default.aspx page should come first.This has to work in programmatic way not using any setting.Hope i explained my problem.

Thanks, Masum

A: 

Have you tried putting

void Session_Start(object sender, EventArgs e)
{
  Response.Redirect("default.aspx");
}

in the Global.asax file?

Pervez Choudhury
Yea i did that...sometimes working and sometimes getting error message "Your application entered in undefined loop that will never end"
+1  A: 

I don't think if there is a programmatical way to set startup page. You can set a redirection to Session_Start but what if user comes from another website that linked your page product.aspx?category=hardware. Do you want him to redirected to default.aspx ?

I thing the clear way is that, remove these files from your application :

  • index.htm, index.html
  • default.htm, default.html
  • index.aspx

then default.aspx will be the only option to redirect.

hope this helps.

Canavar
A: 

You could set a small session variable in the default.aspx page , i.e.

Session("AppInit") = True

and then on every other page_load event do something like this:

   If Session("AppInit") <> True then
     Response.Redirect("Default.aspx")
   End If
EJB
A: 

You could write a HTTP Module to redirect all traffic going to the default URL to a particular page.

Easy to do and you can set it programatically.

Here are some pages: http://support.microsoft.com/kb/307996 http://geekswithblogs.net/flanakin/articles/ModuleHandlerIntro.aspx http://www.15seconds.com/Issue/020417.htm

Andrew Barrett