简体   繁体   中英

Publishing a simple .NET web service yields IIS “It is an error to use a section registered as allowDefinition='MachineToApplication' …”

This error has been reported elsewhere on stackoverflow, but none of the answers seem applicable to my situation.

I'm publishing a simple .NET web service (.asmx) and when I check the link in production, I'm met with the famous error:

"It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS."

I've gone through the basics already, namely these three most popular hints:

1/ The directory has been created as an "Application" by right-clicking in IIS, et cetera. It's running in its own Application pool.

2/ There is no subdirectory containing any superfluous web.config files. It's just the one web.config.

3/ I've made sure that the namespace matches up with the web service definition, all that basic stuff. At any rate, the project runs fine locally and also runs fine when deployed to a test server. This is leading me to think 'permissions issue' on the prod server, but I'm at a loss since the normal IIS sites run fine.

So I guess what I'm asking is: is there a fourth-most-popular cause of this error that I"m missing?

Oh, the Web Service Application is set to allow web service calls for all versions of .NET installed on IIS.

Also, I'd be happy to leave this legacy approach behind and ditch the .asmx for WCF; however this is the piece of code I'm tasked with rolling out at present.

Thanks!

You need to make sure that your have the proper .net framework version selected in you Application Pool. You can check this by going into IIS manager and going to the Application Pools node. Right click on the application pool that is attached to the website that contains your service and select "Basic Settings" (this choice should be in the left hand column of the window too). Then from the drop down select the proper version of the framework. You might need to create a new application pool specifically for the child application if they need to operate on different versions of the framework.

If the parent site is using .net 4.0 your webservice is probably inheriting that or vice versa (2.0).

So in short, try switching your application pool to a different framework version and see if that clears it up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM