Your answer is Routing.
http://msdn.microsoft.com/en-us/library/cc668201.aspx
Look at following code :
public ActionResult Test()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return RedirectToAction("TestAspx");
}
public ActionResult TestAspx()
{
ViewBag.Message = "Your app Test aspx page.";
return View();
}
Here the action TestAspx() returns an TestAspx.aspx view.
And for the Routing
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"TestAspx",
"testganesh",
new { controller = "Home", action = "TestAspx" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new {controller = "Home", action = "Index", id = UrlParameter.Optional}
);
}
Please make appropriate changes to the routing names that you need.
Hope this will help.
Let me know if you still face any issue.
Mark as right if the issue got fixed.
:)
只是为了澄清事实,你想拥有的多个视图一个通过一个URL字符串加载。加载的视图基于未包含在URL字符串中的逻辑...此后,您要加载页面并仍然保留现有字符串。这是你想要达到的目标吗? – AbdulG 2014-10-31 08:12:54
@AbdulG,是的,你得到了点, 让我们说... www.mysite.com/Controller/Action链接应该能够加载任何视图,或webform.aspx页面,而无需更改其URL。 – 2014-10-31 08:49:17
那么你可以通过部分视图实现这一点。使用模板视图(可能只是将其命名为“HandleRequest”,以便它可以与您现有的操作一起返回)。从那里,你可以渲染你的局部视图,在你的模板中,根据你计划使用的任何逻辑来执行 – AbdulG 2014-10-31 09:08:39