Quantcast
Channel: General
Viewing all articles
Browse latest Browse all 7363

Unable to replace the %20 sign into -

$
0
0

Hi All,

I have an url like the following: http://localhost:62009/admin/south%20africa

The url is a routed URL the configuration of which is:

Imports System.Collections.Generic
Imports System.Web
Imports System.Web.Routing
Imports Microsoft.AspNet.FriendlyUrls
Public Module RouteConfig
    Public Sub RegisterRoutes(routes As RouteCollection)
        Dim settings = New FriendlyUrlSettings()
        settings.AutoRedirectMode = RedirectMode.Permanent
        routes.EnableFriendlyUrls(settings)
        routes.MapPageRoute("CountryDetails","admin/{CountryName}", "~/admin/countrydetails.aspx")
    End Sub
End Module

You reach the above url after clicking on a hyperlink inside an asp.net listview control like the below:

<asp:HyperLink runat="server"  CssClass="linkCss" ID="lnkProduct" NavigateUrl='<%# GetRouteUrl("CountryDetails", New With {.CountryName = Eval("CountryName")})%>'>Add a Description </asp:HyperLink>

south%20africa is the Country Name retreived from my database which has been entered as South Africa.

I have implemented a custom rewrite provider (as in http://www.iis.net/learn/extensions/url-rewrite-module/developing-a-custom-rewrite-provider-for-url-rewrite-module) in order to turn the %20 sign into a - sign but the URL still keeps remaining as south%20africa.

In order to register the ReplaceProvider.dll into the GAC, I have used the following command using Windows Powershell:

[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")            $publish = New-Object System.EnterpriseServices.Internal.Publish            $publish.GacInstall("c:\temp\ReplaceProvider.dll")            
iisreset

I have one doubt about the above. In the tutorial above, point 9 says that we also need to Select the "Build Events" tab and add the following "Post-build event" command line:

CALL "%VS90COMNTOOLS%\vsvars32.bat" > NULL 
gacutil.exe /if "$(TargetPath)" 

However, since I am using Visual Studio 2013 Express Edition, I have used the following command line:

CALL "%VS120COMNTOOLS%\vsvars32.bat" > NULL 
gacutil.exe /if "$(TargetPath)" 

I have added the following to my web.config file:

<rule name="ReplaceProviderTest" stopProcessing="true"><match url="%20" /><action type="Redirect" url="{ReplaceProvider:{URL}}" /></rule></rules><providers><provider name="ReplaceProvider" type="ReplaceProvider, ReplaceProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3bea806e4c4ab8d0"><settings><add key="OldChar" value="%20" /><add key="NewChar" value="-" /></settings></provider></providers>

Are there any suggestions about how to rewrite this url?

Thanks


Viewing all articles
Browse latest Browse all 7363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>