Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to force to default.aspx instead of www.domain.com

OK. I'm having a ridiculous problem. I'm trying to use URL rewrite to redirection from www.domain.com to www.domain.com/default.aspx.

I thought by setting default.aspx as the default document it would automatically drop the user there. But for some reason it still comes up www.domain.com.

The reason I want it to go to www.domain.com/default.aspx is that the login control on the page doesn't seem to want to work when it is just the www.domain.com. But of course if I type in the www.domain.com/default.aspx then the login works fine. The login control doesnt seem to post at all if it is www.domain.com. Anyway, I'm trying to avoid troubleshooting why the login control is not firing and just force it to land on default.aspx anytime someone tries to go to www.domain.com. I'm using IIS7. Any ideas here?

like image 532
Timmy J. Avatar asked Dec 28 '22 00:12

Timmy J.


2 Answers

You could add something like this to your Default.aspx code behind (in your Page_Load method):

if (Request.Url.LocalPath == "/")
{
    Response.Redirect("~/Default.aspx");
}

Note that the default document setting normally allows that page to be displayed under www.domain.com/ and www.domain.com/default.aspx (it doesn't do any redirecting for you).

like image 129
Matthew Dresser Avatar answered Jan 13 '23 13:01

Matthew Dresser


The anwer has to do with a breaking change in ASP.NET 4. Answer was that the form action was empty action="" when on extensionless root url. but if on that same page, but had the name of the page in the url (blahblah.com/default.aspx) the action gets filled in. the easy fix for me was to put Me.Form.Action = "Default.aspx" on the page load of the home page. problem fixed.

like image 32
Timmy J. Avatar answered Jan 13 '23 13:01

Timmy J.