I have this url which works absolutely fine on my VS web server
http://localhost:4454/cms/account/edituser/[email protected] (works)
but when I publish this site to IIS7.5 , it simply throws 404.
http://dev.test.com/cms/account/edituser/[email protected] (does not work)
but the strange things happens if I remove email address
http://dev.test.com/cms/account/edituser/email (works , no 404)
but if I change my url with query string it works fine
http://dev.test.com/cms/account/[email protected] (works)
here is my route entry
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new[] { "App.NameSpace.Web.Controllers" }
);
weird thing I have noticed is that when server throws 404 error page , it is a standards iis 404 page not the one custom one I have.
so I was wondering is there any issue with my route mapping
or IIS does not like the url which has email as parameter. but everything works fine with my local dev.
Thanks
Try url encoding the email address in the URL.
EDIT
UrlEncode + Base64?
public static string ToBase64(this string value)
{
byte[] bytes = Encoding.UTF8.GetBytes(value);
return Convert.ToBase64String(bytes);
}
public static string FromBase64(this string value)
{
byte[] bytes = Convert.FromBase64String(value);
return Encoding.UTF8.GetString(bytes);
}
In your view:
<a href="@Url.Action("MyAction", new { Id = email.ToBase64() })">Link</a>
In your controller
function ActionResult MyAction(string id){
id = id.FromBase64();
//rest of your logic here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With