Er. alokpandey's Blog

ASP.NET: Use VB.NET and C# within the App_Code folder

Posted in ASP.NET (C# & VB), C#, VB by Alok Kumar Pandey on January 27, 2011

When I was creating my new blog site (this site your looking at), I chose to write it in C#. I had a problem with the App_Code folder because I had some code in VB.NET code and some C# code I needed to put in there. I didn’t want to rewrite my VB.NET code in the App_Code folder just so I could write the rest of the code for the site in C#.

Luckily, the ASP.NET Team had already thought about just this kind of circumstance. They implemented a way to partition the App_Code folder into sub-folders, one for each set of code files written in the same programming language. Awesome, I didn’t have to spend a couple hours converting code from VB.NET to C#!

The below works with ASP.NET 2.0 and later.

Even if you don’t use multiple different programming languages for your code files in the App_Code folder, you could use this feature to organize your sets of related code files into sub-folders.

Step 1: Add the following lines to the web.config

 

<configuration>
<system.web>
<compilation>
<codeSubDirectories>
<add directoryName=”VB_Code”/>
<add directoryName=”CS_Code”/>
</codeSubDirectories>
</compilation>
</system.web>
</configuration>

Step 2: Create a sub-folder in the App_Code folder for each language you want to support.
For Example:
/App_Code/VB_Code
/App_Code/CS_Code

Step 3: Place your VB.NET code in the VB_Code folder and place C# code in the CS_Code folder.

 

 

Advertisements

4 Responses

Subscribe to comments with RSS.

  1. skin care said, on June 6, 2013 at 7:09 pm

    My programmer is trying to persuade me to move to .
    net from PHP. I have always disliked the idea because of the expenses.

    But he’s tryiong none the less. I’ve been using Movable-type on a
    variety of websites for about a year and am concerned about switching
    to another platform. I have heard very good things about blogengine.
    net. Is there a way I can transfer all my wordpress content into it?
    Any kind of help would be greatly appreciated!

  2. finance adviser said, on May 19, 2014 at 1:28 am

    Every weekend i used to visit this website, because i want enjoyment, for the reason that this
    this website conations actually good funny stuff too.

  3. social jeweller said, on May 20, 2014 at 6:55 am

    These are actually enormous ideas in on the topic of blogging.
    You have touched some pleasant points here. Any way keep
    up wrinting.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: