Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在mvc4中重写动态生成的url_C#_.htaccess_Asp.net Mvc 4 - Fatal编程技术网

C# 在mvc4中重写动态生成的url

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

我的方案是重写基于用户登录动态生成的url。例如,我的url是“mywebsite.com/controllername/methodname?id1=venkatesh%2Fevents”,我想将此url更改为“mywebsite.com/venkatesh/events。我尝试了几种方案,但没有找到合适的解决方案。我尝试了下面的代码,但它没有给出正确的答案,请建议

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();
        }