Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Stop redirect from root to default.aspx

  • 28-02-2010 4:03pm
    #1
    Registered Users, Registered Users 2 Posts: 128 ✭✭


    Hi,

    I have an ASP.NET website and I'm trying to stop the server redirecting the root '/' to the default page '/default.aspx'. I'm on a shared host so I don't have access to IIS. Is there any way of doing this in the code or the web.config file?


Comments

  • Closed Accounts Posts: 1,759 ✭✭✭Dr.Silly


    Hi,

    Only if it's IIS 7.

    <configuration>
    <system.webServer>
    <defaultDocument>
    <files>
    <add value="YOURNEWPAGE.ASPX" />
    </files>
    </defaultDocument>
    </system.webServer>
    </configuration>

    If you're using II6, don't know of another way other than URL mapping.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Could you write a HttpModule to handle it for you?


  • Registered Users, Registered Users 2 Posts: 128 ✭✭johnny_rambo


    Dr.Silly wrote: »
    Hi,

    Only if it's IIS 7.

    <configuration>
    <system.webServer>
    <defaultDocument>
    <files>
    <add value="YOURNEWPAGE.ASPX" />
    </files>
    </defaultDocument>
    </system.webServer>
    </configuration>

    If you're using II6, don't know of another way other than URL mapping.

    This doesn't work on GoDaddy (IIS7). Is there something that needs to be configured server side?
    Could you write a HttpModule to handle it for you?
    I don't know if this will work....I'll look into it before I start coding it.

    I thought this would be an easy thing to fix but it's proving to be a bit of a pain in the ass!


  • Closed Accounts Posts: 22 paul.mcguinness


    Just create the default.aspx with inline code, remove the (Inherits="website.whatever")"

    and place this directly in the aspx file so you wont need to compile it to your project dll
    <script runat=server language=cs>
    protected override void  OnInit(EventArgs e)
    {
      string host = this.Request.ServerVariables["HTTP_HOST"];
          if ((host.ToLower().Contains("default.aspx"))
        {
                  Response.Clear();
                  Response.Buffer = true;
                  Response.BufferOutput = true;
                  Response.Status = "301 Moved Permanently";
                  Response.AddHeader("Location", "http://www.Yourwebsite.ie/mynewindex.aspx");
                  Response.Flush();
                  Response.End();
    }
    
    </script>
    


Advertisement