Redirect from webform to MVC ..getting errors

2019-09-02 21:40发布

I am trying out MVC in existing MVC application . I want to do redirect from webform which is in 'Folder1' to MVC Homecontroller which is in Controllers folder ,same level as Folder1.
I tried this ,its The controller for path '/' was not found or does not implement IController.

UrlHelper urlHelp = new UrlHelper(HttpContext.Current.Request.RequestContext);   
Response.Redirect(urlHelp.Action("About", "Home"), false);

and even tried with

Response.Redirect(HttpRuntime.AppDomainAppVirtualPath + "Home/Index");

even tried this

UrlHelper urlHelp = new UrlHelper(HttpContext.Current.Request.RequestContext);           
Response.Redirect(urlHelp.Action("Index", "Home",new { area = string.Empty }),false);

didn`t work out ..Anybody have idea?

1条回答
男人必须洒脱
2楼-- · 2019-09-02 22:15

Try this?

UrlHelper urlHelp = new UrlHelper(Request.RequestContext);
Response.Redirect(Request.Url.GetLeftPart(System.UriPartial.Authority) + urlHelp.Action("About", "Home"), false);
查看更多
登录 后发表回答