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)
Printable View
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)
You can use the open source Urlrewriter.net
I downloaded the above and added to a dll file.
I then created the following into my webconfig
vb Code:
<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <configSections> <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" /> </configSections> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> <add name="forumConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\forum.mdb;" providerName="System.Data.OleDb" /> <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\forum.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"> <assemblies> <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation> <authentication mode="Forms"> <forms loginUrl="Default.aspx" timeout="2880" /> </authentication> <membership> <providers> <clear/> <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="/"/> </providers> </membership> <profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/> </providers> </profile> <roleManager enabled="true"> <providers> <clear /> <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" /> <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" /> </providers> </roleManager> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> <system.web> <httpModules> <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" /> </httpModules> <customErrors mode="Off"/> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"> <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" /> </modules> <validation validateIntegratedModeConfiguration="false" /> </system.webServer> <rewriter> <rewrite url="~/members/(.+)-(.+)" to="~/members/profiles.aspx?MyTitleId=$2"/> </rewriter> </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?
Read this article
which method should i follow with the open source script?
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>
I gave that ago and still get "The resource cannot be found. "
I have added intelligencia.UrlRewriter.dll TO THE BIN FOLDER
What is the url after re writing ?
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
<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
Did you get the page opened while opening the url ?
http://localhost:2573/runningprofile...px?name=runner
yes i get this page:
http://runningprofiles.com/images/thepage.jpg
Can you please post the modified config file ?
Moved to ASP.Net.