<p>I'm comparing it Java where you can start your application server in debug mode, then attach your IDE to the server. And you can change your code "on the fly" without restarting the server. As long as your changes don't affect any method signatures or fields you can just hit recompile for a class and the application server (servlet container) will reload the class.</p>

<p>I suppose this is impossible in ASP.NET since all classes are packed into assemblies and you cannot unload/reload assemblies, can you ?</p>

<p>So when you have an .aspx page and an assembly deployed to GAC and your codebehind changes you have to redeploy the assembly and reset IIS. I'm talking about Sharepoint applications in particular and I'm not sure whether you have to do iisreset for private assemblies but I guess you have too.</p>

<p>So the best way to debug aspx pages with code behind I guess would be to get rid of the codebehind for the time of active debugging and move into the page, then when it is more or less working move it back to codebehind. (This would be applicable only for application pages in Sharepoint, site pages don't allow inline code )</p>

<p>How do you approach debugging of your ASP.NET applications to make it less time consuming?</p>

[{'answer_id': 31932, 'author': 'Yaakov Ellis', 'author_id': 51, 'author_profile': 'https://Stackoverflow.com/users/51', 'pm_score': 0, 'selected': False, 'text': '<blockquote>\n  <p>And you can change your code "on the fly" without restarting the server</p>\n</blockquote>\n\n<p>You can accomplish this with ASP.net if you make a Web Site project (as opposed to a Web Application Project). Using a Web Site project, you can post changes to code-behinds without having to refresh anything on the server, and the server does the compile work for you on all code changes. See <a href="http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5" rel="nofollow noreferrer">here</a> for more info on this.</p>\n\n<p>This should also solve your difficulties with deploying the assembly to the GAC. As the server handles all compilations for Web Site projects, you wont have to redeploy any assemblies when changing files.</p>\n'}, {'answer_id': 31984, 'author': 'Artem Tikhomirov', 'author_id': 2313, 'author_profile': 'https://Stackoverflow.com/users/2313', 'pm_score': 2, 'selected': False, 'text': '<p>Yes private assemblies <strong><em>DO NOT</strong> require</em> reset of the IIS. So you should just to <em>xcopy</em> new version to the application\'s Bin directory and refresh the page (e.g. by VS post build event as I did).\nBut there are some trade offs. You should decrease trust level in application web.config file: </p>\n\n<pre><code>&lt;system.web&gt;\n    ...\n    &lt;trust level="WSS_Medium" originUrl="" /&gt;\n    ...\n&lt;/system.web&gt;\n</code></pre>\n\n<p>By the way. I do not suggest to deploy like this. It\'s just workaround for comfort write-test-debug cycle length.</p>\n'}, {'answer_id': 40373, 'author': 'Matt Bishop', 'author_id': 4301, 'author_profile': 'https://Stackoverflow.com/users/4301', 'pm_score': 2, 'selected': False, 'text': '<p>If you <em>are</em> using the GAC, you can at least do <code>iisapp.vbs /a "App Pool Name" /r</code> instead of <code>iisreset</code> (it\'s quicker to recycle a single app pool than to restart IIS).</p>\n'}, {'answer_id': 176901, 'author': 'Nat', 'author_id': 13813, 'author_profile': 'https://Stackoverflow.com/users/13813', 'pm_score': 3, 'selected': False, 'text': '<p>From <a href="http://blog.mattsmith.co.nz/Lists/Posts/Post.aspx?ID=45" rel="noreferrer">Matt Smiths</a> blog on how to get F5 debugging with sharepoint. A very cool trick.</p>\n\n<ol>\n<li>Create a web application project in Visual Studio (File -> New -> Project -> ASP.Net Web Application, not File -> New -> Web Site). </li>\n<li>Move the .csproj and .csproj.user files, along with the Properties folder, into C:\\inetpub\\wwwroot\\wss\\virtualdirectories\\, where  is the name or number of the web application corresponding to the SharePoint site you\'d like to debug on. </li>\n<li>Attach the project to an existing solution (e.g. STSDEV project). </li>\n<li>Set as startup project (right-click project name, "Set as Startup Project"). </li>\n<li>Access project properties (right-click project name, "Properties") and click </li>\n<li>Under the "Servers" setting, click "Use IIS web server", then enter the URL to the SharePoint web application you want to debug on, e.g. <a href="http://mymachine:99" rel="noreferrer">http://mymachine:99</a>. </li>\n</ol>\n'}, {'answer_id': 178189, 'author': 'DylanW', 'author_id': 13463, 'author_profile': 'https://Stackoverflow.com/users/13463', 'pm_score': 1, 'selected': False, 'text': '<p>First, develop on a computer running SharePoint. Preferably, this means running Windows Server 2003 on Virtual PC or VMWare. This will let you deploy and debug SharePoint code directly, rather than having to copy files between servers and use the remote debugger.</p>\n\n<p>Use a VS add-in to simplify the process of deployment and debugging. I\'ve been using <a href="http://www.codeplex.com/wspbuilder" rel="nofollow noreferrer">WSPBuilder</a> but I think there are others out there. WSPBuilder has commands to deploy solutions, package them as WSPs, and attach your debugger to the local IIS process. It won\'t allow you to add/remove assemblies on the fly, but you can set breakpoints and run code through the Immediate window in VS.</p>\n\n<p>Depending on how your production server is configured, it\'s usually a good idea to develop on a server with full/trust security settings, including <a href="http://www.dylanwolf.com/programming/144/" rel="nofollow noreferrer">disallowing code blocks in ASPX files</a>. This makes debugging a little more difficult, but it reduces the number of nasty surprises you\'ll have when your code is finally deployed to production.</p>\n'}, {'answer_id': 179702, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Use an automated testing framework (NUnit) to write integration tests. This won't work for everything, but of course, it depends on what you're testing.</p>\n\n<p>If you also have TestDriven.NET installed, you can run individual tests <em>with the debugger</em>. This has been helpful.</p>\n"}, {'answer_id': 179714, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>WSPBuilder Extensions has a "deploy to GAC" shortcut, unfortunately it never works for me. But it\'s a really quick way to code->compile->test.</p>\n\n<p>If you\'re not using WSPBuilder Extensions, you can instead open a command prompt and run </p>\n\n<p>gacutil /u yourassemblynamegoeshere\ngacutil /i yourdllgoeshere.dll</p>\n\n<p>If you do this often, you can put it in a post-build event or in a batch file. Also, I\'m unclear whether the gacutil /u (to remove the DLL first) is necessary.</p>\n'}, {'answer_id': 1953425, 'author': 'Henry', 'author_id': 218924, 'author_profile': 'https://Stackoverflow.com/users/218924', 'pm_score': 0, 'selected': False, 'text': '<p>What it seems like you\'re trying to do is tell Sharepoint "When I start debugging in Visual Studio, use the version of the DLL that was compiled in the project\'s /bin/debug directory instead of the version of the DLL that is registered in the GAC." I haven\'t solved that problem, but here is how I debug Sharepoint.</p>\n\n<p>A developer machine is Win2008, IIS 7, MOSS 2007, VisStudio 2008, and WSP Builder installed. Inside VS2008, a button is added to attach to w3p.exe process, <a href="http://www.andrewconnell.com/blog/archive/2006/05/10/3110.aspx" rel="nofollow noreferrer">Andrew\'s HOWTO attach to w3p</a><br></p>\n\n<p>The solution file has two projects:<br>\n * First project is the .WSP that deploys all the app pages, including the DLL. Use WSPBuilder menu items for handling the .WSP creation and deployment.<br>\n * Second project is for the DLL behind the pages.\n<br><br>\nIf you want the DLL to be copied to the GAC regularly, add a post-build event to the DLL\'s project that copies from /bin/Debug to the GAC. <BR><BR>But, these days, I find I have just been recompiling the solution and then deploying the .WSP using the menu items, and then starting up the debugger using the button.  It takes me an F-key and 3 clicks and about a minute for most of my projects, but I suppose it could be quicker.</p>\n'}]
['https://Stackoverflow.com/questions/31919', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/578/']