Home > DeveloperSection > Forums > How do I handle slash on web.config rewrite
jayprakash sharma
jayprakash sharma

Total Post:117

Points:821
Posted on    January-14-2015 10:12 PM

 ASP.Net C# 
Ratings:


 1 Reply(s)
 740  View(s)
Rate this:

How do I handle product id with slash.

Sample product id: PRODTSP/10

This causes a page error :

"The page cannot be displayed because an internal server error has occurred."

I also tried putting this escaped string to URL, but still the error occurred: PRODTSP%2F10

This is my current configuration:

<rewrite url="^~/Product/id/([^/\\\'=]+)(/?)$" to="~/View/Product.aspx?id=$1"

permanent="true" processing="stop"/>

Thank you



Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    January-14-2015 10:44 PM

<rewrite url="^~/Product/id/([^/\\\'=]+)/?$" to="~/View/Product.aspx?id=$1" permanent="true" processing="stop"/>

<rewrite url="^~/Product/id/([^\\\'=]+)/$" to="~/View/Product.aspx?id=$1" permanent="true" processing="stop"/>

<rewrite url="^~/Product/id/([^\\\'=]+)$" to="~/View/Product.aspx?id=$1" permanent="true" processing="stop"/>

Please try to add this configuration to handle the error.

  • The first line is your original code.
  • The second will handle slash inside the product id and also at the end of the URL.
  • The last will handle slash inside the product id and without slash at the end of the URL.

Modified On Apr-12-2016 12:15:17 AM

Don't want to miss updates? Please click the below button!

Follow MindStick