Best Method for Converting a Web Application into an IIS Website - asp.net

I have a Web Application and want to move/make it as a IIS website
1. Not Copying the DLL
When I copy every part of the code except the Web Application's built DLL file I come up with an error
"could not load type ..."
2. Copying the DLL
cloning that DLL also shouldn't be practical.
If we copy the DLL so the site will work as expected
but after any changes to code-behind other problems will occur
"... does not contain a definition for btnABC_Click() ...."
What should be our decision or strategy in this case
--
I want to make an IIS-Version of the project because of fixing some addressing-Paths issues
thanks in advance

When the Web site runs, ASP.NET code in your Web page doesn't call the C# code that you've written in your code-behind files. Rather, it calls a compiled version of that C# code that is in the application's DLL file.
So the C# code in the code-behind must be compiled after any change into a new version of what you refer to as the "web application's built DLL".
Otherwise your Web page will refer to an old version of the DLL, hence the errors "... does not contain a definition for ...".
You may want to investigate the walkthrough here: http://msdn.microsoft.com/en-us/library/1y1404zt(v=VS.100).aspx
and read the background material here: http://msdn.microsoft.com/en-us/library/377y0s6t.aspx
as they explain in fine detail what you'll need to do.

Related

Reasons for : xxx.aspx has not been pre-compiled and cannot be requested (it is pre-compiled)

hoping someone has some insight into this issue I get pretty commonly.
I have an ASPX Web Application that is pre-compiled. I have this application running within another IIS application working flawlessly. The parent application has an "updatable=false" property within the PreCompiledapp.config.
Now I need to add more pages to my application, which I create the same way in visual studio, and publish them with the rest of the application. When I open these files to check them in notepad, I can see the "This is a marker file generated by the precompilation tool, and should not be deleted!" as well as the .compiled file that generates with it.
On a local machine and application instance, this works... but when I copy the same applicaiton build to a client (same application, same pages, same everything) it gives me the " xxx.aspx has not been pre-compiled and cannot be requested " error.
What could be some causes of this? The pages are pre-compiled so I'm wondering if this can be thrown for something else. Any help is appreciated thanks!
I think the cause may be the parent application is set with updatable=false but the ASPX Web Application which you published is allow update. So it may lead to this problem. The same error message and the cause are described in detail here.
To solve this problem is convert your application to web application(has its own AppDomain and configuration) or publish the root application as updatable as well.

asp.net publish on iis 6 - masterpage fail

I'm working at an ASP.net application.
When I debug the local Project, it works and everything is okay.
I tried to publish the project directly from Visual Studio 2010 via File System. The publish work and there are no errors. But if I call the project via browser, I get the error
The file 'pagemaster.master' does not exist.
I have to say that this project doesn't contain the master. The master is in an other project. But I added this project to the solution and I also added a reference to the other project. And as I already said, the project works locally.
Can anybody help me fix this?
Check first if it's working in local because of an hidden old copy of the master page (in the solution view check show hidden files).
After this, if you reference a master page from another project, you need to be sure that the fiscal non-code-behind part of it is copied in the resources.
To assure that you should set the property of the master page to Embedded Resource and access it using a VirtualPathProvider mechanism to call the Resource.
It's a bad solution, but also your approach is really "unconventional" :( You should consider other way to recycle code and templates from common projects.

Old VS2008 ASP.NET web site project doesn't update DLL in bin after building

I have inherited an old ASP.NET web site project (not a web project), so it uses the web site model from what I gather. There is no code in the App_Code folder. There are dozens of aspx and aspx.cs files in a different folder.
What I have done so far:
I have copied the entire project locally from the previous person's fileshare (he's gone and didn't use TFS).
I loaded the web site in VS2008, made a small change to an email address in the code and rebuilt it.
At this point, it compiles fine, no errors. But the dlls in the bin folder do not reflect the proper date/time stamp. I published the site to the test server and it is still using the previous email address before I updated it.
My problem: Why would the dll not get updated? I have read there is a difference between a web site model and a web application model. When I select Build from the menu, it actually says "Build Web Site", and not the project name. This is my first experience using this type of project.
My Question: Any ideas what I can do to resolve? I have already combed through similar questions on this site but the ones that are closest to my issue don't have resolve/answered status.
Thanks
From what I recall, didn't websites perform runtime compilation and hence not generate a dll? Don't quote me on that though, it's been a while. Could you convert it to a web application from VS?
You should have a solution with at least two projects:
Sln
- Website
- DLL
On the Website add a reference to the DLL and build. Should take care of it.
Alternatively you could convert to a Web Application as well, but you'd have the same problem if your project structure is not correct.

Updating a DLL in a Production ASP.NET Web Site bin folder

I want to update a class library (a single DLL file) in a production web application. This web app is pre-compiled (published). I read an answer on StackOverflow (sorry, can't seem to find it anymore because the Search function does not work very well), that led me to believe that I could just paste the new DLL in the bin folder and it would be picked up without problems (this would cause the WP to recycle, which is fine with me because we do not use InProc session state).
However, when I tried this, my site blows up and gives a FileLoadException saying that the assembly manifest definition does not match the assembly reference. What in the world is this?! Updating the DLL in Visual Studio and re-deploying the entire site works just fine, but it is a huge pain in the rear. What is the point of having a separate DLL if you have to re-deploy the entire site to implement any changes?
Here's the question: How can I update a DLL on a production web site without breaking the app and without re-deploying all of the files?
The thing to remember is that there are web sites and web applications as far as Visual Studio and ASPNET is considered.
Web Sites typically have all of the aspx and vb files published to the live server and ASPNET Worker Process recompiles the app every time before presentation.
On the other end is the web application, where all of your code behind files get compiled down to a single DLL file and you simply deploy your aspx pages and you bin folder with the DLL file to production.
There is also a "hybrid" known as "Precompiled Web Sites" (see the link for the official MSDN overview) where you don't have the single DLL layout of a web application, but all the compile work of the website is done for you. There are several "modes" to this depending on your needs.
It seems to me that your error is caused because your site is set up as a web site with some kind of precompilation in place. Using the pre-compiled model is a little more "strict" in that is assumes certain files/signatures are in place. Having an updated version of the DLL file causes a break since the precompilation wants a name and a version of the file.
If possible, your best bet would be to convert to a web application, since you can add the additional DLLs into production without a problem. Otherwise, take a look at this matrix to see what form of precompilation you need for your application.
Look at this SO post, might be what you are referring to. The located assembly's manifest definition does not match the assembly reference
Have a look at your reference. Does it say "specific version = true" ? Set it to false, republish your app (you have to do it once, because now your app is still looking for an assembly with a specific manifest) and try it again.

ASP.NET isn't automatically rebuilding

If you create an ASP.NET Web Site project and run it, you get a blank page. If you go into the default CodeBehind file, add into the Page_Load method throw new Exception();, save the file, and refresh it in the browser (without rebuilding), the server automatically rebuilds the project and the page will error.
I have a project that I am working on now where refreshing the page does not cause the project to be rebuilt (the new aspx files are used but the old DLLs are used with them). What causes this, and how do I correct it?
Is this new project a web application project by any chance? I believe you have to actually build that before changes will be seen.
Web Application Project is a separate type of project that requires all code behind to be build. The resulting dll is build under the bin folder. The code behind files are not used in execution, and is the preffered way of doing it if you don't want to expose your code at the installed web server, and to be sure execution is faster (never compiling in runtime).
When you creatied it as "ASP.NET Web Site", it is NOT a "Web Application Project".
Only code which is in App_Code will be automatically recompiled when it changes. If your code lives anywhere else, then it's part of the pre-built DLL you get when you hit "compile".
You are using the Website model. The pages will be compiled when you access them. Class Library projects in the same solution will not. Hence why you see this behaviour.
By default, the ASPX, code behind and App_Code source files get compiled. If you have a seperate project in the solution (a BLL or DAL perhaps), these will not be updated by simply refreshing the browser.
So to correct it you could do a proper build in Visual Studio, or you could move the class files you want to change into App_Code. Personally I'd stick with the former (actually I don't ever use the Website option- always Web application project).
OK. Have you got 'Edit and Continue' enabled?
MSDN

Resources