将 EF 4.1 代码优先 ASP.NET MVC3 部署到中等信任共享托管

发布于 2024-11-05 15:24:40 字数 838 浏览 0 评论 0原文

我认为,这是当今很常见的情况,所以令人惊讶的是,我很难找到好的和干净的解决方案(即使在这里)。

我的 ASP.NET MVC3 Web 应用程序使用 Entity Framework 4.1 和代码优先方法(使用 DatabaseInitializer 来播种默认数据)。我还尝试了两个数据库选项:SQL Express 2008 R2 和 SQL Compact 4。在本地一切正常。

现在我想托管我的应用程序,所以我找到了 托管 (中间一个称为“最佳” ')最后(在出现一些问题之后)进入状态,我遇到了中等信任错误(我相信)。

应用程序尝试执行 不允许的操作 安全政策。为了授予此 申请所需的权限 请联系您的系统 管理员或更改 应用程序的信任级别 配置文件。

让我们假设我无法以任何方式配置该托管,并且我不认为他们会将我切换到完全信任。

我必须做什么,才能使我的应用程序在中等信任托管上工作?

编辑:我找到了一些通常在本地开发人员中传播设置中等信任的答案,然后就这样做了,所以我的问题现在可能是这样的:

您的 ASP.NET MVC3 EF 4.1 应用程序无法在中等信任度下工作的“前 5 个原因”是什么?

编辑:我为此添加了赏金,因为我想看看一些讨论..或者至少更多的意见/经验,不仅仅包含“在本地开发人员中设置中等信任”。也许这里没有什么可讨论的,但我只是好奇,因为我已经在这上面花费了比我想要的更多的时间。

I think, this is quite common situation nowadays, so its surprising, that I have troubles finding nice and clean solution for it (even here at SO).

I have my ASP.NET MVC3 web application using Entity Framework 4.1 with code-first approach (using DatabaseInitializer to seed default data). I also tried two database options: SQL Express 2008 R2 and SQL Compact 4. Everything is working fine on local.

Now I want to host my app so I found hosting (middle one called 'optimal') and finally (after some issues) got into state, where I am getting medium-trust error (I believe).

The application attempted to perform
an operation not allowed by the
security policy. To grant this
application the required permission
please contact your system
administrator or change the
application's trust level in the
configuration file.

Let's take as fact that I can't configure that hosting any way and I do not think, that they are going to switch me to full-trust.

What do I have to do, to make my application work on medium-trust hosting?

Edit: I have found some answers that are usually propagating setting medium trust at local dev and just do it like that, so my question could now be something like:

What are "top 5 reasons" why your ASP.NET MVC3 EF 4.1 app won't work at medium-trust?

Edit: I have added bounty to this becuase I would like to see some discussion.. or at least more oppinions/experiences, containing more than just "set medium trust at local dev". Maybe there is nothing to discuss here, but I am just curious because I already spent more time on this than I would like.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

从此见与不见 2024-11-12 15:24:40

当服务器没有 .NET 3.5 Service Pack 1 时,我看到其他人抱怨同样的错误,并且能够通过将 DLL 放入其 bin 文件夹中来解决该问题。

这里还有一些关于一些需要检查的事情的更多信息:
log4net 在 ASP.Net MVC Web 中抛出安全异常应用程序

I've seen other people complain of the same error when the server did not have .NET 3.5 Service Pack 1 and were able to work around it by putting the DLLs in their bin folder.

There's also a little more info here about a few things to check:
log4net throwing Security Exception in ASP.Net MVC web application

凤舞天涯 2024-11-12 15:24:40

您有最新的 EF Code First 库吗? RC 之前的所有内容都不是中等信任兼容的。

如果您要使用 SQL CE 4,它是中等信任兼容的,但您是否部署 SQL CE 数据库引擎文件

您确定您的问题是 EF Code First 吗?又名 - 您是否尝试过先部署一个简单的 MVC 站点并使其运行? 这是一篇关于在中等信任度下设置 MVC 的文章 和另一篇文章在 bin 为尚未运行/支持 MVC3 的主机部署 MVC3

Do you have the latest EF Code First library? Everything before the RC was not medium trust compatible.

If you are going to use SQL CE 4, it is medium trust compatible but did you deploy the SQL CE database engine files?

Are you sure your problem is EF Code First? AKA - Have you tried just deploying a simple MVC site first and getting it running? Here's an article on setting up MVC in medium trust and another on bin deploying MVC3 for hosts who aren't running/supporting MVC3 yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文