skip to Main Content

I am trying to navigate a dotnet codebase, which is hosted on IIS. I can only see aspx files, and not the csharp files. I presume there should be a App_Code folder somewhere, but I can’t find it amongst the aspx and other files.

I have a few questions:

  • I don’t see any business logic in the aspx code, then how does the application work?
  • How do ‘runat=server’ thing works?

I tried navigating the IIS server, but could not find any csharp or vb code. I also searched the C drive of the machine where the IIS server is installed. I can only find some boilerplate and auto-generated csharp code.

2

Answers


  1. Well, keep in mind like some html page?

    asp.net pages are driven by vb.net or c# code behind.

    In other words, asp.net systems are applications.

    When you build say a desktop application, or whatever?

    Well, to run such applications, then the code is compiled, source code is stripped out, and then the result is some. dll’s that contains the compiled code and logic that drives the application.

    So, just like any compiler code environment, the source code is stripped out when you build and deploy that application. That is the heart and soul of .net applications, and this approach applies to asp.net web applications.

    So, you can in most cases move the application to a new hosted server, and you don’t need the source code. However, often the database connections etc. will no doubt have to be changed (found in web.config).

    So, you not going to find the source code, or the so called "code behind pages". They are stripped out, removed and such code is compiled into dll’s.

    You can find those .dlls in the bin folder.

    So, you can freely in most cases move that application to another server. However, what you can’t do is modify the site unless you have Visual Studio, and have the project file used to create the application. As noted, the project files, the source code, and an IDE like Visual Studio will be required to modify that program.

    This is not really any different then me handing you a desktop program. You can’t really modify that program UNLESS I give you the project file that was used to build the application.

    So, you not going to find the source code, since that code exists in the source project used to build the application, not in the final compiled and deployed application.

    So, unlike some simple HTML pages that represent a web site?

    Asp.net web applications don’t work that way. So, you will requite the source project file. During development, you have a mix of .aspx files, and each file will also then have a code file. This source code file is for all practical purposes required to make any code changes to the application.

    While this is a fantastic setup?

    About the only downside is if you make ONE LITTLE change to the c# (or vb.net) code? Then you have to a full re-deploy of the WHOLE site, since such code, subroutine calls, classes and objects used? Well, the final compiled code thus has to include all those bits and parts referenced in that program. Upon build and publish, then all of those resulting. dll’s are then placed in the bin folder. And depending on the publish options used, you might see/find a boatload of. dll’s, or if the "merge" options were used, then you only find one .dll, or at the very least just a few. It much depends on the libraries used. So, say if you using newton soft, or GhostScript.net (to process PDF files), then of course you often find additional. dll’s included in the project, and these additional libraries (.dlls) will also be pushed out to the bin folder at application build/compile and at publish time.

    Visual Studio and asp.net is a code centric developer system. Thus, such applications are not just based on some HTML markup, but a real object-based development system. So, you not see the final source code when the application is compiled and built.

    So, you can in most cases move the resulting folder to another computer. However, to modify the application, then you need the original source code and Visual Studio project used to create the site. You will not find the project nor the source code on the web server.

    However, I should point out that some older WebForm’s used a project type called "asp.net web site". In that case, then YES the code source files are placed on the server. The advantage of this setup was that then ONE page could be changed, and deployed to the server.

    So, keep in mind that some asp.net webform sites did include the source code files. This makes updates to the site rather easy, but then means the web server (IIS) is compiling the code, and thus your not using Visual Studio to compile the code.

    The names of the two types of projects are thus very simular.

    The two projects choices are:

    Asp.net webforms web site
    

    and

    Asp.net webforms web application.
    

    The difference being the term "application".

    The two choices in Visual Studio are thus this:

    Web site application – source code not deployed to web site:

    enter image description here

    And then a asp.net web site – source code is deployed to web site:

    enter image description here

    So, to be fair, you will often find some webforms sites that include both the aspx pages, and also the code behind pages such as aspx.vb (for vb.net) or aspx.cs (for c#).

    As noted, there are far more limitations with just a "web site", and thus from a developer point of view, the "application" type of project is preferred by developers. These projects allow including multiple projects, and far better class object resolution at compile time.

    However, the web site choice does have that one significant advantage in that most cases you can simple copy the .aspx page, and the aspx.vb/c# code page to the site and you are done.

    Login or Signup to reply.
  2. Current ASP.NET Web Forms have the code behind source code (the code in *.cs or *.vb files) compiled into DLL files and placed into the BIN folder when deploying the application. The ASPX file refers to the namespace and class which is then referenced by each of the objects, and IIS handles all of that.

    To make a change to the application or to figure out how it works, you need the source code, make the changes, recompile the application and deploy.

    One note, I think some of the commenters might not know that a "Web Site" type project used to exist in Visual Studio, where .CS files would be placed into the App_Code folder, and would be deployed WITH the application. The files were referenced in the ASPX file with the CodeFile directive rather than the CodeBehind directive, and I think that’s what you’re referencing in your question and why the confusion may exist.

    Administrators could then make on the fly changes to the website by changing the deployed source code, and IIS would trigger a recompile of the site.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search