Global.asax.cs does not appear on the server

Work in Server08 | IIS7. I have a website project and I'm used to manually editing Global.asax.cs on a deployed site many times in the past. I recently discovered that only the Global.asax file is present and has only:

<%@ Application Codebehind="Global.asax.cs" Inherits="myDomain.MvcApplication" Language="C#" %> 

There are simply no Global.asax.cs files available / visible for any of my active, functioning websites.

I checked here Global.asax cannot find the code class below and here where are the Global.asax codes in mvc3? I’m not going anywhere. The second link contains a comment: "This is because it is a compiled web application. You will need to view it in Visual Studio as a project. '

But since my project has always been a website - and I haven’t converted it (intentionally), I am puzzled by the changed behavior.

But when I enter VS12 and look at the context menu for the WebProject solution, it represents "Convert to Web Application". Folder structures on sites do not contain App_Data or App_Start. In my opinion, these two facts, which are installed in VS, consider the project as a website, why is Global.cs compiled to / bin then?

I will close by repeating - in the past I edited these things - I'm not sure, but you can probably say that this is the first time I tried to do this after installing VS12. And thinking about it is more difficult - only recently I implemented the "One Click Publishing" service so that it could enter the game.

check? I would like to I need to edit a simple update without fully redeploying.

THX

+4
source share
3 answers

I think One Click Publishing is most likely a criminal. I created a sample web site for experimentation, and when I use the publishing function in Visual Studio, the generated files do not really have the Global.asax.cs file. Instead, a bin folder is created with a compilation called "App_global.asax.dll", even if it is a website and not a web application. I suppose this may be similar to what is happening for you.

If not, I found a link that may be useful to you, again to be able to edit the class on the server. In particular, look at the second answer (one that is not accepted as the best answer) to recreate the class file for the global code: Where is the Global.asax.cs file?

I tried this solution and checked that the class file is editable on the server and that it compiles dynamically at runtime (the changes I made to the file worked immediately).

Hope this helps!

+4
source

After editing global.asax, you need to rebuild and load the DLL into the bin folder. Otherwise, your changes will not take effect.

0
source

You may be able to download the web version of global.asax, which includes code in this single file, which obviously does not require .cs code. I used to do this with aspx files in an application, but I never tried it in the GLobal.asax file.

0
source

Source: https://habr.com/ru/post/1436246/


All Articles