ASP.NET MVC 3 Views Always Red in IDE
For some reason in Visual Studio if i have some controller code like :
public class HomeController : Controller
{
public ActionResult Index()
{
return View("SpecialView");
}
}
SpecialView will be highlighted red despite me having a .cshtml file available at Views/Home/SpecialView.cshtml. The application will compile fine and work fine in a browser. If I right click and hit 'go to view' it will say the view can't be found.
Its more of an annoyance than a big deal. I am running VS 2010 w/ M开发者_开发知识库VC 3 and the April tools update.
"Go To View" is work for only same name view and method pairs. If you have ~\Home\Index.cshtml you can open Index page with it. But not for "SpecialView" because it is only one of View method parameters. It can be many views right. suppose
swich (hede)
{
case 1:
return View("MyView1");
case 2:
return View("MyView3");
default:
return View("MyDefaultView");
}
"Go to view" try to go only method name. for your sample it will try to find Index.cshtml.
精彩评论