url rewriting

Discussion in 'Visual Studio' started by hemal, May 9, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi,

    VS 2005 is the platform.

    I have got a website that works on httpcontext.rewritepath on global.asax to generate friendly urls.

    As suggested, I've tried to install & work with url rewriting as you described in the forums link below: http://www.codeproject.com/aspnet/URLRewriter.asp#xx1425096xx

    However, I have had not luck getting this to run on my local server- it keeps giving me an error:

    Error2Cryptographic failure while signing assembly 'd:\WINDOWS2\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web application\f9aaf7e4\12f576be\App_Code.d_rheqxm.dll' -- 'Error reading key file 'keyfile.snk' -- The system cannot find the file specified. '

    If you can help me out here? Am I doing something wrong.
    Here's what I did
    - Download the source files
    - Register Thundermain.rewrite... .dll in the %windir%/assembly folder
    - Added thundermain...dll to my bin directory
    - Added the rewriter.cs file to my project
    - added consigsection code
    - added <urlrewrites> in the system.web section :: gives me a warning saying that this tag was unidentified!
    Is there no way you guys can allow httpContext.RewritePath on Global.asax?
    - added ThunderMain.Rewriter.Rewrite.Process() in the Application_BeginRequest() method

    Now, I compiled the code to get this error?

    Any help here?

    Also, is there no way you can allow httpcontext.rewritepath on global.asax or is it already allowed &amp; i do not need to go through the whole process of installing "thundermain".

    Thanks
     
  2. When you download the zip from codeproject, you should be able to just copy the dll from the bin into your bin directory and start using the control.

    Are you getting this error about the keyfile.snk when you are trying to compile this project or your own project?


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  3. Hi,

    Yes this error is about the keyfile.snk

    I get the error in both cases. I tried the simplistic approach in the first place:
    1.run the downloaded source files on its own as project - didn't work
    2. then i tried using them inmy project -didn'twork :) no surprises here

    It wasafter this that I tried the whole nine yards
     
  4. You could remove this line from the .cs file...





    [assembly: AssemblyKeyFile(@"keyfile.snk")]



    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  5. Hi Joel,

    No more errors - only a warning - but the build is successful.

    The warning is as follows:
    The element 'system.web' has invalid child element 'urlrewrites'

    Rewrite Condition is still not working.

    <urlrewrites>
    <rule>
    <url>/lingerie/(.*)\.aspx</url>
    <rewrite>category.aspx?category=$1</rewrite>
    </rule>
    </urlrewrites>

    I want every link: http://localhost/Web%20Application/lingerie/Chemise.aspxto be rewritten to

    http://localhost/Web%20Application/category.aspx?category=Chemise

    My configSections code is as follows:

    <configSections>
    <sectionGroup name="system.web">
    <section name="urlrewrites" type="ThunderMain.URLRewriter.Rewriter,
    ThunderMain.URLRewriter, Version=1.0.783.30976,
    Culture=neutral, PublicKeyToken=7a95f6f4820c8dc3"/>
    </sectionGroup>
    </configSections>
     
  6. Sorry hang on My Ooppss..

    missed a step - Didn' t uncomment ThunderMain.URLRewriter.Rewriter.Process();

    When I did do that

    I got this error:

    Error2The type 'ThunderMain.URLRewriter.Rewriter' exists in both 'd:\WINDOWS2\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web application\f9aaf7e4\12f576be\App_Code.cz-zuv6q.dll' and 'd:\WINDOWS2\assembly\GAC\ThunderMain.URLRewriter\1.0.783.30976__7a95f6f4820c8dc3\ThunderMain.URLRewriter.dll'D:\CFS\CURRENT CLIENTS\Underworld Fashions\Web Application\Global.asax1033D:\...\Web Application\


    I have uninstalled the Thundermain.URLRewriter.dll from the %Windir%/assembly path.

    Still get the same error on build

    Error2The type 'ThunderMain.URLRewriter.Rewriter' exists in both 'd:\WINDOWS2\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web application\f9aaf7e4\12f576be\App_Code.apk9y3ik.dll' and 'd:\WINDOWS2\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web application\f9aaf7e4\12f576be\assembly\dl3\52015de0\00f9382b_a91cc201\ThunderMain.URLRewriter.DLL'D:\CFS\CURRENT CLIENTS\Underworld Fashions\Web Application\Global.asax1033D:\...\Web Application\
     
  7. Eureka...

    Wonder why this didn't work before... just one of those things you need someone to baby sit youon :)

    Its all good and working now - undid everything and just re-did everything .. works like a charm...

    all i had to do was:
    1. Add Reference from thedownloaded sourcecode into my local project
    2. Add configsections tags
    3. Add urlrewrites tags


    Great stuff.. thanks Joel :)
     
  8. Hi again,

    Its been sometime. I have got the above url rewriting working on the hosting. Here is a related issue for another website still to do with url rewriting.

    This time it works on my local server but not on the remote server.

    Rule is:
    <urlrewrites>
    <rule>
    <url>/r/(.*)/c/(.*)/</url>
    <rewrite>/Default.aspx?region=$1&amp;category=$2</rewrite>
    </rule>
    <rule>
    <url>/c/(.*)/</url>
    <rewrite>/Default.aspx?category=$1&amp;region=</rewrite>
    </rule>
    <rule>
    <url>/r/(.*)/</url>
    <rewrite>/Default.aspx?region=$1&amp;category=</rewrite>
    </rule>
    </urlrewrites>

    So, website.com/r/Asia/c/Chips/ would be rewritten as website.com/Default.aspx?region=Asia&category=Chips

    This works well on my local server, however not on the discountap.net server? Any Clues? On the remote server, the page simply dies with a '404' error message

    Thanks :)
     
  9. You might need to have * mapped to the asp.net ISAPI dll. If you have not done this, contact support and they can set this up for you.



    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page