Click here to Skip to main content
14,267,341 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi im new to ASP.net. I am wondering how to redirect to an 'index.cshtml' page in ASP.net. Please help!

What I have tried:

Response.Redirect("index.cshtml");
Posted
Updated 19-Jul-19 10:37am
Comments
Bryian Tan 25-Sep-17 12:31pm
   
Is the web application using MVC architectural pattern? If that the case, do something like

Response.Redirect("~/ControllerName/ActionName");
Nalini123456 25-Sep-17 12:40pm
   
I am trying to redirect the nav tab in bootsrtap to the index.cshtml page. So here is my code for the nav tab:

Inventory Module
Add Inventory
<a data-toggle="pill" href="Response.Redirect("~/ControllerName/ActionName");"List
Rate this:
Please Sign up or sign in to vote.

Solution 2

The redirection will be based on the project structure you are using.

NORMAL ASP.NET
If you are not using any area's concepts then just Response.Redirect("Yourpage.aspx")

MVC - WITH AREAS Concept
<a href="@Url.Action(&amp;quot;Controller/ActionMethod&amp;quot;)" title="Modules">

MVC - WITH AREAS Concept
</a><a href="@Url.Action(&quot;Areas/Controller/ActionMethod&quot;)" title="Modules">

MVC - WITH AREAS Concept and T4MVC
</a><a href="@Url.Action(MVC.AreaName.Controller.ActionMethod())" title="Modules">


If you could'nt resolve this even after the above help, the easiest way is to use the developers tools in chrome.

Press F12, Go to Network and then click the button you will see the 404 error and the network URL in that.

The developerstools in chrome will help you out in finding where the issue is


https://developer.chrome.com/devtools/images/networkanel.png - Sample image

Check how it is trying to access and then proceed from there.

My 1st suggestion is kindly install the T4MVC from the nuget pakages and start using that to avoid these problems.
   
v2
Comments
Vaidhya.P 26-Sep-17 3:38am
   
Kindly let me know if the above answer is not supporting you.
Rate this:
Please Sign up or sign in to vote.

Solution 3

<a data-toggle="pill" href="@Url.Action("ActionName", "ControllerName")>List</a>


Leave the "Controller" suffix off the controller name, so if the class is called HomeController you use just "Home" as the controller name.
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

Ok here is the solution if anyone is having the same problem
just remove the data-toggle="pill" and it works fine.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100