Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
69
rated 0 times [  76] [ 7]  / answers: 1 / hits: 5479  / 8 Years ago, tue, june 7, 2016, 12:00:00

I'm developing an ASP.Net MVC 5 project . I need to redirect page when I submit something. I used this Javascript code :



return Content(<script language='javascript' type='text/javascript'>alert('Edited...');window.location.href = 'ShowColor';</script>);


when I edit something in



http://localhost:56583/Admin/EditColor/27



I want redirect my page to



http://localhost:56583/Admin/ShowColor



With above code it goes to



http://localhost:56583/Admin/EditColor/ShowColor



Also I used below code according to Redirecting to action from javascript but it didn't work too :



return Content(<script language='javascript' type='text/javascript'>alert('Edited...');window.location.href = '@Url.Action('ShowColor', 'Admin')';</script>);


I have no idea how fix it. thanks for any help


More From » asp.net

 Answers
19

I believe this is due to relative paths. Something like the below should make it relative to the domain.



window.location.href='/Admin/ShowColor'

[#28235] Sunday, June 5, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
louiseb

Total Points: 368
Total Questions: 107
Total Answers: 107

Location: Tanzania
Member since Wed, Feb 24, 2021
3 Years ago
;