如何重定向到ASP.NET中的另一个C#页面 [英] How to redirect to another C# page in ASP.NET

查看:47
本文介绍了如何重定向到ASP.NET中的另一个C#页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ASP.net的新手。我想知道如何重定向到ASP.net中的'index.cshtml'页面。请帮帮忙!



我的尝试:



 Response.Redirect(index.cshtml); 

解决方案

重定向将基于您正在使用的项目结构。



NORMAL ASP.NET

如果你没有使用任何区域的概念,那么只需要Response.Redirect( Yourpage.aspx)



MVC - WITH AREAS概念

< a href =@ Url.Action(& amp; amp; 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和T4MVC

< / a>< a href =@ Url.Action(MVC.AreaName.Controller.ActionMethod())title =Modules>





如果您在上述帮助后仍无法解决此问题,最简单的方法是使用开发人员工具chrome。



按F12,转到网络,然后单击按钮,您将看到404错误和网络URL。



chrome中的开发人员工具将帮助您找到问题所在




https://developer.chrome。 com / devtools / images / networkanel.png - 示例图片



检查它是如何尝试访问然后从那里继续的。



我的第一个建议是从nuget pakages安装T4MVC并开始使用它来避免这些问题。


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





将Controller后缀保留在控制器名称后面,因此如果该类称为HomeController,则只使用Home作为控件ler name。


这里有解决方案,如果有人遇到同样的问题

只需删除data-toggle =pill,它就可以了。

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");

解决方案

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.


<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.


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


这篇关于如何重定向到ASP.NET中的另一个C#页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆