Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Pls some one tell that how to redirect one page to another page after clicking link in mvc4. After clicking the link the error is


Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Views/Home/Index.cshtml
Posted

1 solution

The Url which you have mentioned is wrong.
By default the route config in MVC accepts url like
{controller}/{Action}/{id,parameters if any}
So the views/Home/Index.cshtml is the folder level search which is not required here.
You should access the page with:-
Home/Index only.
This will redirect to a new page, considering Home is the controller, Index an action and the Action method has a view defined like below

C#
public ActionResult Index()
{
    return View();
}


C#
<html>
    <head>
         <title>XYZ</title>
    </head>
    <body>
        //anything here....
    </body>
</html>


then access from layout with:
C#
@Html.ActionLink("Click(ActionName goes here)","Index(Action method name)","Home(Controller name)")


Thanks
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900