model view controller - Url problems in MVC C# -


i have problem in mvc project in url.

in route config have following code:

routes.maproute(            name: "test",            url: "{controller}/{action}/{id}/{selected}/{category}/{engineid}‌​",            defaults: new { controller = "product", action = "subcategories"}        ); 

the parameter category contains name of selected category. in database have category name: "packet / set". if in website choose category , in url appear categoryname

subcategories/92/bertone-freeclimber-2.0/packet / set /33720‌%e2%80%8b. 

i got the

 server error in '/' application.  resource cannot found.  

error. if the category name doesn't contain "/" character, evrything works fine:

subcategories/94/bertone-freeclimber-2.0/air%20filter/33720%e2%80%8c%e2%80%8b 

could advise how should resolve this?

you need encode slashes in url %2f. can use javascript encodeuricomponent() function. mvc automatically decodes url , action parameters should able values correctly in controller without additional effort. take here more info: https://www.w3schools.com/jsref/jsref_encodeuricomponent.asp


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -