How do I deploy an IIS ASP .NET application with f

2019-06-25 16:13发布

问题:

We have an industrial system, which can be interfaced using some C++ DLLs given to us. I wrote a .NET wrapper to control the industrial system, then bundled this .NET wrapper into an ASP .NET web application so we can control the system over the web.

Everything works fine when I run/debug in Visual Studio using the ASP .NET Development Server. When I deploy to the local ISS server I'm getting an error from the C++ DLLs that (I'm told) means that there's a communications fault.

Because the IIS app and the Dev Server are on the same machine, and one works and the other doesn't, I'm convinced that this is a permissions/security error. I've spent days fiddling with Application Pool identities, ASP .NET impersonation, filesystem permissions etc. to no avail. (I'm also a bit of an IIS-noob, which doesn't help.)

So, here's the punch-line:

Could somebody please explain how (if it's possible) to set up an IIS ASP .NET application so that it's running with full (balls-out, guns-blazing) access to the local machine? I want to ensure that IIS is not holding the application back by anything.

回答1:

I am not sure if giving full trust mode will resolve your issue since the error seems to be coming from C++ and either some kind of permission at file system level is missing or the file itself is missing.

In any case, to answer your question, you can set full trust mode using the web.config, add following section to your web.config:

<system.web>
 <securityPolicy>
   <trustLevel name="Full" policyFile="internal"/>
 </securityPolicy>
</system.web>

More details can be seen here : http://msdn.microsoft.com/en-us/library/wyts434y.aspx



回答2:

Besides setting a full trust level in the ASP.NET application itself, check the user the IIS uses for anonymous access to your website/web app:

Web app -> Properties -> Directory Security -> Edit (at Authentication and access control).

(This path is for IIS6.)

By default the IIS assigns a user with cut-down permissions, which can cause issues you are experiencing.