拼图:
我在Visual Studio中运行的解决方案可以使用IISExpress按预期运行和运行.
要设置我的网站以使用IIS,我尝试了以下步骤:
此时,我收到一个HTTP 500.21
错误.
我也尝试aspnet_regiis.exe -i
使用Visual Studio的命令提示符(作为管理员)运行,但每次运行该命令时,我都会收到以下错误:
命令'aspnet_regiis.exe'无效.
我还确认我确实aspnet_regiis.exe
安装了(通过在此处查看)(.NET Framework版本4(64位系统)).
在IIS 7.5中注册.NET Framework 4.5需要做什么?
iis-7.5 windows-7-x64 asp.net-mvc-4 asp.net-4.5 visual-studio-2013
我需要以数据库中两个不同模型的列表形式将数据发送到MVC4项目中的视图.
像这样的东西:
控制器:
public ActionResult Index()
{
Entities db = new Entities();
ViewData["Cats"] = db.Cats.toList();
ViewData["Dogs"] = db.Dogs.toList();
return View();
}
Run Code Online (Sandbox Code Playgroud)
查看:
@* LIST ONE *@
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.ListOneColOne)
</th>
<th>
@Html.DisplayNameFor(model => model.ListOneColTwo)
</th>
<th>
@Html.DisplayNameFor(model => model.ListOneColThree)
</th>
</tr>
@foreach (var item in @ViewData["Cats"]) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.ListOneColOne)
</td>
<td>
@Html.DisplayFor(modelItem => item.ListOneColTwo)
</td>
<td>
@Html.DisplayFor(modelItem => item.ListOneColThree)
</td>
</tr>
@* LIST TWO *@
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.ListTwoColOne)
</th> …
Run Code Online (Sandbox Code Playgroud) 我能够适当地利用ASP.NET MVC4 OutputCache和以下代码作为我的Controller的索引()的属性:
[OutputCache(Duration = 600, VaryByParam = "none")]
Run Code Online (Sandbox Code Playgroud)
然而,
为了管理不同的缓存场景,根据MSDN文档,我们可以使用OutputCache缓存(例如)我们的控制器Index()方法.在文档之后,我们最终得到以下代码:
在我们的控制器中
//[OutputCache(Duration = 600, VaryByParam = "none")] //works without any modification to the Web.config
[OutputCache(CacheProfile = "Cache1Hour", VaryByParam = "none")]
public ActionResult Index()
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
而在我们的Web.config
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="Cache1Hour" duration="3600"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
...
...
...
</system.web>
Run Code Online (Sandbox Code Playgroud)
问题/问题: 显然我错过了一些东西,因为我不断抛出以下异常:
异常详细信息:System.Web.HttpException:未定义"Cache1Hour"缓存配置文件.请在配置文件中定义它.
完全例外:
Server Error in '/' Application.
The 'Cache1Hour' cache profile is not defined. Please define it in the …
Run Code Online (Sandbox Code Playgroud) 该InitializeDatabaseConnection方法的文档说,我们可以用SQLCE(SQL Server精简4.0本地数据库)使用MVC 4"互联网"模板的生成会员功能.
我之前已经多次使用过这个模板,并且在我没有弄乱任何东西时只是使用了我们第一次注册用户时实体框架生成的localDb(默认).
我的要求是将默认情况下生成的成员资格表生成到2012 localDb数据库中,而不是生成到SQLCE数据库中.但是,我得到以下内容:
例外:无法找到请求的.Net Framework数据提供程序.它可能没有安装.
要做到这一点,我们只需:
~/App_Data/
文件夹(右键单击该文件夹,然后选择添加 - > SQL Server Compact 4.0本地数据库).<add name="ceEntities"
)的名称~/Filters/InitializeSimpleMembershipAttribute
类中找到以下代码行:WebSecurity.InitializeDatabaseConnection("ceEntities", "UserProfile", "UserId", "UserName", autoCreateTables: true);
到目前为止,代码编译并运行正常,但是当在~/Filters/InitializeSimpleMembershipAttribute
类中运行以下代码行时:
WebSecurity.InitializeDatabaseConnection("ceEntities", "UserProfile", "UserId", "UserName", autoCreateTables: true);
Run Code Online (Sandbox Code Playgroud)
捕获此异常: 无法找到请求的.Net Framework数据提供程序.它可能没有安装.
当我们将此代码添加到web.config时,这显然是修复的:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" /> …
Run Code Online (Sandbox Code Playgroud) asp.net-membership sql-server-ce asp.net-mvc-4 entity-framework-5