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

    global.asax file


    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;
    true );

    Thanks in advance!

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

    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,


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

    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: