0

I want to redirect from one view to another view in the same project/solution. There are 3 hyperlinks in here and I am unable to redirect to either of them. Can someone help me with this?

<body>
  <div>
    <br />
    <span style="margin-left:20%"></span>
    <a href="~/Views/Corporation/ForgotLoginId.cshtml">Forgot Login ID?</a>
    <br />
    <br /><span style="margin-left:20%"></span>
    <a href="~/Views/Corporation/ForgotPassword.cshtml">Forgot Password?</a>
    <br />
    <br />
    <span style="margin-left:20%"></span>
    Need to register your Corporation?
    <a href="~/Views/Corporation/CorporationRegistrationPg1.cshtml">Click here</a>
  </div>
</body>

When I try to click on the hyperlink, I am getting the following HTTP 404 Not Found error. I tried many approaches, but none seem to work.

error

I tried different approaches to linking to the controller. But, I failed to get any positive output.

1 Answer 1

1

Asp.net does not have phyiscal routing - you do not want to link to physical files. Instead it resolves its routes after a pattern. The default pattern, unless specified otherwise is "{controller}/{action}/{id}".

So assuming your controller is called CorporationController, and your action method is called "ForgotPassword", the hyperlink would be constructed with:

@Html.ActionLink("Forgot Password", "ForgotPassword", "Corporation")

You might want to read some basic documentation about Asp.Net Mvc first.

Sign up to request clarification or add additional context in comments.

1 Comment

To expand on @Marco's suggestion: Documentation for ASP.NET Routing; Documentation for ActionLink(). If you're using ASP.NET Core, the format is a bit different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.