ASP.NET MVC 前台html中怎么使用后台的C#代码。
我在Controller中年,写了一个方法。里面拼凑的是 html。想呈现在view页面指定位置。请问要怎么做?
在网上百度的方法:
1.使用方法:@Html.Action(action, controller)
加载局部页面。
例如在模板页中使用:@Html.Action("Contact", "Company")
在CompanyController中有如下方法:
public PartialViewResult Contact()
{
return PartialView();
}
使用这个办法,会报错。用户代码未处理HttpException。