asp.net web application with c# & vb.net both in c

2019-07-21 16:10发布

问题:

We currently have a asp.net website with some modules developed in VB.Net & some in C# (not just classes but also individual aspx pages and code behind). We figured we wanted to move to web application model as we need to implement CI with TFS.

The problem :

When we create a C# web application, copy the files from website & say convert to web application it gives Could not Parse errors (probably because files are vb.net files)

When we create a VB.NET web application, copy the files & say convert to web application it converts only vb.net pages & on publishing throws error on all c# pages saying Could not load type

The asp.net website would work properly with multiple codebehind language support.

Help would be highly appreciated!

回答1:

Can you break the app into 2 separate web applications that run from the same root directory? Just put the complied C# dll in the bin with the compiled VB.net dll and place all of the aspx pages wherever they would need to be for your site structure.

I haven't tried this myself, but it should work. You'll have to create a separate project and reference any data layers, etc. Just move the C# code to the new app and see how that goes. Not the best solution, but it beats converting from one language to another.



回答2:

Put all the App_Code folder names what contain C# code into CodeSubDirectories section in your web.config

p.s. this is how it's done in DotNetNuke



回答3:

You can do this with web sites but not web applications. Also note that if you want or need to do this Web applications really don't have any additional level of power that web sites lack. Web applications can have deployment benefits in some environments but visual studio 2010 and 2012 will publish asp.net web sites and web applications both with ease.