My environment is Visual Studio 2005. My specific problem is that I want to define TRACE.
I have a Web Site Project that send trace messages when run out of the ASP.NET Development Server thanks to defining it in the system.codedom element of the web.config.
When I deploy to IIS, I do so via a web deployment project. So the site is precompiled. Naturally, these entries serve no purpose on a compiled website.
My question is how do I define TRACE in the web deployment project?
The visual Studio IDE does not allow you to set compile time constants in web deployment projects as far as I can tell. However, since a .wdproj file is just an msbuild file, you can edit it with a text editor. You need to add a element to the sections as illustrated in the screen shot in the provided link.
I cannot change the link to an image since new users apparently can't add images:
Annotated screenshot of .wdproj in a text editor http://img140.imageshack.us/img140/1719/deploymentproject.png
There is no equivalent to #defines in C#. That said, it sounds like you want to use conditional tracing, which is easily accomplished. If you have diagnostic code throughout your project but want to define it, use the built in trace functionality, for example
System.Diagnostics.Trace.WriteLine("Some debug output");
Then, in your webconfig, you can configure it on/off using
<configuration>
<system.web>
<trace enabled="true" requestLimit="40" localOnly="false"/>
</system.web>
</configuration>
More info here
Related
We recently converted a website made with .Net WebForms from a Web Site project, to a Web Application Project.
This is all well and good, except it's now a pain because to change any of our code-behind files we have to rebuild the whole site, whereas before all we had to do was save the code-behind file.
This means changing pages in logged in areas requires not only rebuilding the whole Web Application, but then logging in again for a user.
Is there a way to remove the precompile option while running locally so we can debug as we used to with a Web Site project?
I have tried removing the <compilers> section from the web.config, and also removed the <compilation> too, but neither seem to have made a difference.
EDIT:
I realise now I wasn't very clear. I'm talking about debugging the site locally, not when publishing.
No.
Web Application projects load from a DLL; they have no option to compile source at runtime.
You should specify a fixed validation & decryption keys in Web.config so that users don't need to log in again after deploying (more detail).
I currently am attempting to create a UI Module for IIS. I plan on using it on IIS 7 and up.
I have followed several different tutorials.
I used the source from this link for testing after it failed to work the first time.
Creating a UI Module For IIS7 to watch Current Requests
I did more looking here
How to Create a Simple IIS Manager Module
My end goal is to have a button within IIS (as it is in the first link).
I am getting the assembly into the GAC (%windir%/assembly), I checked that.
I then added
<add name="CurrentRequestsUI" type="CurrentRequestsUI.RequestModuleProvider, CurrentRequestsUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=269f1cc1a4bf892b" />
within the moduleProviders section of my administration.config (%windir%/System32/inetsrv/config)
then added <add name="CurrentRequestsUI" /> in the modules section of the same file.
Right now I'm just using sample source to see if I can get that to work before I start my project. I apologize for if I'm posting this in the wrong place. If you want me to provide more information, ask and I will provide it.
My question is how do I add a custom UI Module to IIS?
Thanks in advance for the help!
I had been editing the administration.config file within Visual Studio and Notepad++ (32-bit applications), but I then opened the 'same' file within Notepad (64-bit application). Making changes within Notepad made the changes within the proper file.
Opening 32-bit applications such as Notepad++ and Visual Studio 2010 opened the wrong file
%windir%/SysWOW64/inetsrv/administration.config
Opening 64-bit applications such as Notepad opened the correct file
%windir%/System32/inetsrv/administration.config
I would like to use web.config transformation but do not see the "Add Config Transforms" in the context menu when i right-click on my original web.config file.
I do not have a Web Application Project and cannot have one. My solution has a few projects for BLL, DAL etc, then i have a local IIS website for the main Website.
Under my local IIS website i have a web.config and have tried to add a web.Debug.config like such:
How can i do web.config transformation using the localhost IIS website and not having to creating a Web Application Project? Is it even possible? Is creating a Web Application Project a requirement?
I was recently reading up on this subject and to my knowledge you can not do web.config transformation in a Web Site project for one simple reason – Web Sites don’t have project files, which is where the msbuild configurations are stored. So if you need that functionality you will have to create a project file. But have a look at this blog which I think gives a better explanation for this.
http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/
Having said that if you do find out that im wrong, which i might be please keep me updated with what was your solution
Thanks
I want to include configuration for the Application Warmup module for IIS 7.5 in my application's web.config file ( an <httpWarmup> element inside <system.webServer>)
This works fine when the module is installed, but if I want to deploy the application to a server without the module installed (e.g. IIS Express) I get
HTTP Error 500.19 - Internal Server
Error
The requested page cannot be
accessed because the related
configuration data for the page is
invalid.
Can this be done? Is there a setting to make IIS ignore extra elements in <system.webServer> that it doesn't recognise?
Thanks
If you're using Visual Studio 2010 then you can use the web.config transformation feature. Using transformations you can, in combination with the website 'Publish' tool, transform your web.config and add/remove settings depending on whether you're doing a debug or release build.
For more information see:
Web.config Transformation Syntax for Web Application Project Deployment
How to: Transform Web.config When Deploying a Web Application Project
Scott Hanselman has a great demo of this feature:
Web Deployment Made Awesome: If You're Using XCopy, You're Doing It Wrong
This works with ASP.NET 2.0 and 4.0.
If you're still using Visual Studio 2008 then it's still possible to achieve this.
First off is to use a brute force approach and maintain multiple web.config files. When you build the project in VS you use a pre-built event swap in the correct web.config file. I've used this technique before but Scott Hanselman (as always) has a nice worked example:
Managing Multiple Configuration File Environments with Pre-Build Events
If you're using MSBuild directly then you could use a build task to modify the web.config files. There's an extension library available from the MSBuild Community Tasks Project which provides additional extensions to MSBuild to make these tasks easier. The XmlMassUpdate task is probably the task you'd want to use. I'll be honest and admit that I'm only scratching the surface of MSBuild at the moment and haven't actually tried this, but (and I don't mean this in a LMGTFY way) googling XmlMassUpdate returns a rich seam of useful looking hits.
I find it really hard to find clear documentation on IIS7 and integrated mode. Apparently the system.webserver section is for IIS7 integrated mode... but, does IIS7 Integrated Mode ignore a system.web section? + Can you configure everything from the system.web section in the system.webserver section?
There's a tool to migrate from IIS6 to IIS7. If I run it, a lot of things still remain in system.web. Most application even run in Integrated Mode without changing web.config... so, please, explain me why there was a new section needed? I really don't get it.
System.WebServer section is "processed" by IIS7 and the asp.net engine is not involved. Earlier (pre - IIS7), the configuration system of IIS (metabase.xml) and ASP.NET (the heirarchy of web.config) were completely different, but in IIS7 a unified configuration is generated at run time for app pool.
The IIS7 configuration file is stored here: C:\Windows\System32\inetsrv\config. This one has the system.WebServer.
This has architectural implications in the sense that (at least in theory) now asp.net modules can be executed even for a non asp.net application.
You can look at the default app pool config here: C:\inetpub\temp\appPools\DefaultAppPool
There are more details, but this should get you started.
It is strange that you said the documentation is hard to find, as Microsoft this time keeps a centralized portal for it,
http://www.iis.net/ConfigReference
The changes made by the migration tool are all documented in this article,
http://learn.iis.net/page.aspx/381/aspnet-20-breaking-changes-on-iis/
You can read it through to understand why certain tags are modified.