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

URL Rewriting with .net

  • 17-09-2009 8:31pm
    #1
    Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭


    Hi,

    I've developed a web application that utilises UrlReWrite.Net to allow me to use clean SEO URLs. This works great on my local machine, but not on the web server.

    I contacted my web host and they've informed me that my application is hosted on a server using IIS 7, and this has a URL rewriting component provided by M$. I've searched for info on this but the only method of creating them I can find is through a UI within IIS that writes the rules to the web config.
    <rewrite>
      <rules>
        <rule name="Rewrite to article.aspx">
          <match url="^article/([0-9]+)/([_0-9a-z-]+)" />
          <action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}" />
        </rule>
      </rules>
    </rewrite>
    

    When I add these to my web config it breaks the web app so I think I'm putting them in the wrong place. I've tried system.web and in the root but its still the same.

    Anyone know where exactly in web.config I need to put them?

    Thanks in advance :)


Comments

  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Rewrite to article.aspx">
              <match url="^article/([0-9]+)/([_0-9a-z-]+)"/>
              <action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}"/>
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    

    There you go :)


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Ginger wrote: »
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Rewrite to article.aspx">
              <match url="^article/([0-9]+)/([_0-9a-z-]+)"/>
              <action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}"/>
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    

    There you go :)

    You're a gentleman Ginger, thanks very much! :)


  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    Just re. what your host told you they may have been referring to the fact that IIS7 handles routing without wildcards. i.e. since asp.net 3.5 we have routing which allows us to use friendly urls in a much easier way than before. Asp.net MVC uses it but it is not exclusive to MVC. If you are hosting on IIS7 you owe it to yourself to check out routing - http://msdn.microsoft.com/en-us/library/cc668201.aspx.


Advertisement