简体   繁体   中英

Referencing code in App_Code from web.config

I have a type in my App_Code folder from a Web Site project that I want to refer to in Web.config. The type attribute is requiring me to put in an assembly name. The internets is failing me with what to put in for the assembly.

Specifically in,

<system.web>
    <webServices>
        <soapExtensionReflectorTypes>
            <add type="MyType, $App_Code$" />
        </soapExtensionReflectorTypes>
    </webServices>
</system.web>

What do I put in $App_Code$ to make it compile? I've tried _ _ code, App _code, App _Code (Markdown is failing here: those type names don't have spaces in them)

OK, I found the answer on some obscure MSDN forum: you can't do that in a Web Site project for system.web/webservices/soapExtensionReflectorTypes. Only a Web Application Project will suffice.

I found a work around for a Web Site project. I moved the type out of the App_Code folder and put it in a new class library, compiled and added to the bin directory.

Now the web.config section finds the type through

<soapExtensionReflectorTypes>
    <add type="MyNamespace.MyType, FileTitleOfLibrary"/>
</soapExtensionReflectorTypes>

The second argument is the filename of the library without the file extension.

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