![h-ui asp.net](https://i-blog.csdnimg.cn/blog_migrate/d255ff5cd0bcb8e698465c9e23287103.png)
h-ui asp.net
If you're getting started with ASP.NET 4, there's a few things you might run into that could throw you for a loop if you didn't expect them. Remember that while ASP.NET is a very compatible release, it is also a side-by side release so this was a good time to make breaking changes for the better.
如果您刚开始使用ASP.NET 4,可能会遇到一些事情,如果您不期望它们,可能会使您陷入困境。 请记住,虽然ASP.NET是一个非常兼容的发行版,但它也是并行发行的版本,因此这是一次更好地进行重大更改的好时机。
Note that just installing ASP.NET 4 won't break your applications. You can happily run all your ASP.NET applications side by side each in their own AppPool. These first two "gotchas" below are if you're moving an existing application over to .NET 4. The third gotcha is an install ordering thing.
请注意,仅安装ASP.NET 4不会破坏您的应用程序。 您可以在自己的AppPool中愉快地并排运行所有ASP.NET应用程序。 下面的前两个“陷阱”是将现有应用程序移至.NET 4的情况。第三个陷阱是安装订购的东西。
默认情况下,“请求验证”更为严格。 (Request Validation is more strict by default.)
Request validation is more strict by default in ASP.NET 4. Pretty much anyone moving a non-trivial ASP.NET 2 application over to ASP.NET 4 has a good likelihood of running into this. The workaround is pretty simple. If you want to revert the behavior of the validator to pre-ASP.NET 4, add this to your web.config:
默认情况下,ASP.NET 4中的请求验证更加严格。 将非平凡的ASP.NET 2应用程序迁移到ASP.NET 4的几乎任何人都有可能遇到这种情况。 解决方法非常简单。 如果要将验证器的行为还原为ASP.NET 4之前的版本,请将其添加到web.config中:
<httpRuntime requestValidationMode="2.0" />
That's it. Of course, you can always dig in a bit and see why your app doesn't like the stricter validation and fix that as well.
而已。 当然,您总是可以深入研究一下,看看为什么您的应用程序不喜欢更严格的验证并进行修复。
“我将我的ASP.NET 2 / 3.5应用程序切换到了ASP.NET 4应用程序池,但由于我没有运行VS2010升级向导而崩溃了” ("I switched my ASP.NET 2/3.5 application over to an ASP.NET 4 application pool and it broke because I didn’t run the VS2010 upgrade wizard")
If you just go into IIS and change your existing app's AppPool to ASP.NET 4, you might get an error. The nitty gritty details are here, but the average customer's brain will melt reading the details.
如果您只是进入IIS,并将现有应用程序的AppPool更改为ASP.NET 4,则可能会收到错误消息。 细腻的细节在这里,但是普通客户的大脑会熔化阅读这些细节。
So instead, a quick way to fix this (assuming you don't want to upgrade the app) is
因此,一种解决此问题的快速方法(假设您不想升级该应用程序)是
- Make sure you have SP2 installed if they are running Vista and Windows Server 2008. If you are in Windows7 then no service pack is needed.如果它们运行的是Vista和Windows Server 2008,请确保已安装SP2。如果您使用的是Windows7,则不需要Service Pack。
- Go to your application's web.config and wack the standard <configSections> definition at the top. 转到应用程序的web.config并在顶部显示标准的<configSections>定义。
- Although not required, toss the <system.codedom> section towards the middle of the web.config since it isn’t needed either. 尽管不是必需的,但也可以将<system.codedom>部分扔到web.config的中间。
That's it.
而已。
“我安装了ASP.NET 4,然后安装了IIS。” ("I installed ASP.NET 4 and then installed IIS.")
If you install VS2010 and/or .NET 4 first, then later install IIS, you need make sure IIS is configured to know about ASP.NET 4 otherwise IIS will have no idea how to run ASP.NET 4 applications.
如果先安装VS2010和/或.NET 4,然后再安装IIS,则需要确保将IIS配置为了解ASP.NET 4,否则IIS将不知道如何运行ASP.NET 4应用程序。
There's a simple workaround:
有一个简单的解决方法:
If you are already in this state, drop to the command line and navigate to the FX install directory. Then run "aspnet_regiis –iru".
如果您已经处于此状态,请转到命令行并导航到FX安装目录。 然后运行“ aspnet_regiis –iru ”。
- Note if you are on a 64-bit machine, run this command from the 64-bit FX install directory – not the 32-bit installation directory. 请注意,如果您使用的是64位计算机,请从64位FX安装目录(而不是32位安装目录)运行此命令。
or for future reference, try to enable IIS and the ASP.NET extensibility option *first* when your are building machines or VMs. That way when VS 2010 or .NET are subsequently installed, the installation will automatically detect the presence of IIS and will auto-register with it.
或以供将来参考,尝试启用IIS和ASP.NET扩展选项*第一*当你正在构建机或虚拟机。 这样,当随后安装VS 2010或.NET时,安装将自动检测IIS的存在并自动向其注册。
Hope this helps. The complete list of ASP.NET 4 Breaking Changes is here.
希望这可以帮助。 ASP.NET 4重大更改的完整列表在这里。
翻译自: https://www.hanselman.com/blog/aspnet-4-breaking-changes-and-stuff-to-be-aware-of
h-ui asp.net