Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bill 81 posts 83 karma points
    Jun 03, 2011 @ 17:17
    Bill
    0

    global.asax file

    hello,

    I want to add the code below to the global.asax file. how do I do that in umbraco?

    protected void Application_BeginRequest( object sender, EventArgs e){
       //check the request to make it starts with www
       //and is not localhost (dev)
       if (!Request.Url.Host.StartsWith( "www" ) && !Request.Url.IsLoopback)
       {
          //no ... redirect.
          
     UriBuilder builder = new UriBuilder (Request.Url);
          builder.Host = 
    "www." + Request.Url.Host;
          Response.Redirect(builder.ToString(), 
    true );
       } 
    }

    Thanks in advance!

  • Marco Fernandes 15 posts 51 karma points
    Jun 04, 2011 @ 16:45
    Marco Fernandes
    0

    You could do it in a package. 

    The final step of a package installation can be a user control.

    Within the user control you could add the code to write to the global.asax.

     

    Best regards,

    Marco

  • Bill 81 posts 83 karma points
    Jun 04, 2011 @ 19:36
    Bill
    0

    Thank you very much for the reply... but actually this was the first thing that I tried but this leads to an error...

    So after some research I found an article that said tha you could create your own Global.Asax that inherits from Umbraco.Global and after doing that you delete the App_Global.dll from the bin folder... Oh... and don't forget that the above class must override...

Please Sign in or register to post replies

Write your reply to:

Draft