Results 1 to 15 of 15

Thread: [RESOLVED] Url Re-writing

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Resolved [RESOLVED] Url Re-writing

    How do you url-rewrite with vb.net?

    I want to create a profile page where users can go to: www.mysite.com/members/profiles.aspx?name=?? via www.mysite.com/members/(name)

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Url Re-writing

    You can use the open source Urlrewriter.net
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: Url Re-writing

    I downloaded the above and added to a dll file.

    I then created the following into my webconfig
    vb Code:
    1. <?xml version="1.0"?>
    2. <!--
    3.   For more information on how to configure your ASP.NET application, please visit
    4.   http://go.microsoft.com/fwlink/?LinkId=169433
    5.   -->
    6.         <configuration>
    7.             <configSections>
    8.                 <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
    9.             </configSections>
    10.     <connectionStrings>
    11.         <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
    12.             providerName="System.Data.SqlClient" />
    13.         <add name="forumConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\forum.mdb;"
    14.             providerName="System.Data.OleDb" />
    15.         <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\forum.mdf;Integrated Security=True;User Instance=True"
    16.             providerName="System.Data.SqlClient" />
    17.     </connectionStrings>
    18.     <system.web>
    19.         <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
    20.             <assemblies>
    21.                 <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    22.                 <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    23.                 <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    24.             </assemblies>
    25.         </compilation>
    26.         <authentication mode="Forms">
    27.             <forms loginUrl="Default.aspx" timeout="2880" />
    28.         </authentication>
    29.         <membership>
    30.             <providers>
    31.                 <clear/>
    32.                 <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
    33.             </providers>
    34.         </membership>
    35.         <profile>
    36.             <providers>
    37.                 <clear/>
    38.                 <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
    39.             </providers>
    40.         </profile>
    41.         <roleManager enabled="true">
    42.             <providers>
    43.                 <clear />
    44.                 <add connectionStringName="ApplicationServices" applicationName="/"
    45.                  name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
    46.                 <add applicationName="/" name="AspNetWindowsTokenRoleProvider"
    47.                  type="System.Web.Security.WindowsTokenRoleProvider" />
    48.             </providers>
    49.         </roleManager>
    50.     </system.web>
    51.     <system.webServer>
    52.         <modules runAllManagedModulesForAllRequests="true"/>
    53.     </system.webServer>
    54.                         <system.web>
    55.                 <httpModules>
    56.                     <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
    57.                 </httpModules>
    58.            <customErrors mode="Off"/>
    59.     </system.web>
    60.             <system.webServer>
    61.                 <modules runAllManagedModulesForAllRequests="true">
    62.                     <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
    63.                 </modules>
    64.                 <validation validateIntegratedModeConfiguration="false" />
    65.             </system.webServer>
    66.             <rewriter>
    67.                 <rewrite url="~/members/(.+)-(.+)" to="~/members/profiles.aspx?MyTitleId=$2"/>
    68.             </rewriter>
    69. </configuration>

    but when i type in

    http://localhost:2573/runningprofiles/members/jarratt

    i get the error The resource cannot be found.

    Am i missing something?

  4. #4
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Url Re-writing

    Read this article
    Please mark you thread resolved using the Thread Tools as shown

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: Url Re-writing

    which method should i follow with the open source script?

  6. #6
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Url Re-writing

    Change this


    Code:
      <rewriter>
    
                    <rewrite url="~/members/(.+)-(.+)" to="~/members/profiles.aspx?MyTitleId=$2"/>
    
                </rewriter>

    to


    Code:
     <rewriter>
    
                    <rewrite url="~/members/profiles.aspx?name=(.+)"  to="~/members/$1" />
    
                </rewriter>
    Please mark you thread resolved using the Thread Tools as shown

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: Url Re-writing

    I gave that ago and still get "The resource cannot be found. "

    I have added intelligencia.UrlRewriter.dll TO THE BIN FOLDER

  8. #8
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Url Re-writing

    What is the url after re writing ?
    Please mark you thread resolved using the Thread Tools as shown

  9. #9

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: Url Re-writing

    well i type in http://localhost:2573/runningprofiles/members/runner

    and it does not even re writing

  10. #10
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Url Re-writing

    Quote Originally Posted by runnerjp View Post
    well i type in http://localhost:2573/runningprofiles/members/runner

    and it does not even re writing

    Here it is like ~runningprofiles/members but we re write using

    ~/members/profiles.aspx?name=(.+)

    You need to change that one. And from url type

    http://localhost:2573/runningprofile...px?name=runner

    and see what happens
    Please mark you thread resolved using the Thread Tools as shown

  11. #11

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: Url Re-writing

    <rewriter>

    <rewrite url="~runningprofiles/members/Profiles.aspx?name=(.+)" to="~/members/$1" />

    </rewriter>

    you mean like this ^^

    http://localhost:2573/runningprofile...px?name=runner

    i tried this and no re-write

  12. #12
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Url Re-writing

    Did you get the page opened while opening the url ?

    http://localhost:2573/runningprofile...px?name=runner
    Please mark you thread resolved using the Thread Tools as shown

  13. #13

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    15

    Re: Url Re-writing

    yes i get this page:


  14. #14
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [RESOLVED] Url Re-writing

    Can you please post the modified config file ?
    Please mark you thread resolved using the Thread Tools as shown

  15. #15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width