tags:

views:

942

answers:

2

My default document is in subfolder not in root how can i make it default in asp.net 2.0 website.

Tried iis7 default document setting to '/pages/default.aspx' '~/pages/default.aspx' but it didn't work.

+1  A: 

Default documents are a subfolder-specific thing - what you're trying to do won't (directly) work. Set up a default.htm file in the root, and have it refresh to your real "home page".

The better question you should be asking is how on Earth your homepage got out of the root directory.

Greg Hurlman
A: 

Default document is not the same as start page. Default document means if I requested mysite.com/somefolder and didn't specify a file, which file should IIS display.

If you want to use a specific page as your home page, create a Default.aspx file and write this in it's codebehind class:

public override void ProcessRequest(HttpContext context) {
    context.Response.Redirect("pages/default.aspx", true);
}

As the client might have disabled Javascript, a server side approach would be more reliable. However it's best to issue a permanent redirect instead of a simple Response.Redirect. Also doing it using JS will be bad from a SEO point of view.

Mehrdad Afshari
Doing it code-behind is an unnecessary drag on time - one line of JavaScript is all you need.
Greg Hurlman
If you want to avoid JS, an HTML meta-refresh is another easy HTML-only solution.
Greg Hurlman