C# 在mvc4中重写动态生成的url
我的方案是重写基于用户登录动态生成的url。例如,我的url是“mywebsite.com/controllername/methodname?id1=venkatesh%2Fevents”,我想将此url更改为“mywebsite.com/venkatesh/events。我尝试了几种方案,但没有找到合适的解决方案。我尝试了下面的代码,但它没有给出正确的答案,请建议C# 在mvc4中重写动态生成的url,c#,.htaccess,asp.net-mvc-4,C#,.htaccess,Asp.net Mvc 4,我的方案是重写基于用户登录动态生成的url。例如,我的url是“mywebsite.com/controllername/methodname?id1=venkatesh%2Fevents”,我想将此url更改为“mywebsite.com/venkatesh/events。我尝试了几种方案,但没有找到合适的解决方案。我尝试了下面的代码,但它没有给出正确的答案,请建议 namespace MvcApplication3.Controllers { [RouteArea("area")]
namespace MvcApplication3.Controllers
{
[RouteArea("area")]
[RoutePrefix("event",Precedence=1)]
[RoutePrefix("student", Precedence = 2)]
public class Default1Controller : Controller
{
//
// GET: /Default1/
[GET("venkatesh")]
[GET("venkatesh-event",IgnoreAreaUrl=true)]
public ActionResult Index()
{
ViewBag.info = "This is index method";
return View();
}
//
// GET: /Default1/Details/5
[GET("event{id}")]
public ActionResult Details(int id)
{
ViewBag.info = "This is details method"+id;
return View();
}