Visual Studio Keep Session between rebuilds etc - visual-studio

I would like to know if there is a way to keep the session going.
I've got sick of losing my session between rebuilds/builds, if I change too much in my project or submit code to our SVN (tortoise via VisualSVN). I'm developing an ASP.NET MVC project with lots of jQuery.
I would like to do this as I test my project on one screen with Firefox (Firebug wins) and edit on the other in visual studio. As my project has a session system and I would like to be able to develop without having to keep re-logging into my system.
Thanks
Edit:
Visual Studio 2008 Professional with the build in IIS development server.
Windows Vista Business 64bit

I don't think that's possible, given that the application restarts on each build. What you could do though, is add a temporary jQuery post call to the login page, that will run on startup.
$(function() {
$.post('/login/', { username: 'phil', password: 'noonewillguessthis' });
});
That way you'll be logged on to the system "automatically" each time the page loads. Just remember to remove it before you deploy live... ;)

It is not possible, when you rebuild and change the content of your libraries they have to be reloaded into the process space. However, in .Net you can never remove assemblies from an AppDomain once they are loaded. To reload your library the AppDomain needs to be unloaded and loaded again. In addition, if there are any changes to your web.config, it will also unload/reload your AppDomain.
You could use something like pushing session state to SQL server so that the AppDomain recycle doesn't impact you. You can do this with the sessionState element of the web.config file.

I have faced the same problem. I use VS 2015 on a machine. I rebuild/build project and on my first debugging the first generated session is lost. Think i mention about 2 paged project. first page is "Default.aspx", second page is "Home.aspx".
Default.aspx page is loaded first
Session["UserID"] is generated on Default.aspx
Page is redirected to Home.aspx by using Response.Redirect("Home.aspx",false) code.
Session["UserID"] is checked on Home.aspx.cs' s Page_Load function if it is existing or not
Session["UserID"] is not existing.. lost!
Solution:
I have instaled Visual Studio on other machine and I built the project on that machine. As result session missing problem is solved. Publishes are worked well on servers too. Maybe this problem is sourced by Visual Studio configurtions or machine configurations, I am not sure but installing VS may solve the problem.

Related

Web Publish to Package Hangs

I have an ASP.NET MVC website project that is a few years old. When it's time to deploy an update to QA or Production, I use Web Publish to create a ZIP file and related .cmd file.
It worked fine this morning. Then I updated the project from source control. Now, when I right-click the project and select Publish..., Visual Studio 2013 hangs. After some initial research, I have tried the following:
Run as Administrator
Disable Anti-Virus (temporarily)
Clean the solution
Delete the .suo and .csproj files
Rebooted
Gave it 20 minutes to see if it unhangs
I also deleted the /Properties/PublishProfiles folder with the existing .pubxml files. When I do that, the publishing wizard opens and allows me to name a custom profile, at which point it, along with Visual Studio, hangs. No .pubxml file is written in this case.
While Visual Studio is hanging, it is not consuming any significant CPU.
What else can I try?
As it turns out, another developer inadvertently checked in a change to web.config, providing an incorrect connection string for the application's database. The web application startup code accesses the database to pre-cache some information. I'm unsure why there is no connection timeout, but that is not relevant to answering this question.
The Web Publish wizard must be causing the web application to run. Since that startup code was essentially hanging, so did the Web Publish wizard.

Visual Studio ignoring breakpoints

Visual Studio is ignoring my breakpoints. I don't know if it makes a difference but this is happening in Web API. I know it's passing over my code because I can put Console.WriteLine('FOO'); in and it shows up. But it passes over my breakpoints like they aren't even there. I added System.Diagnostics.Debugger.Break(); and that gives me this dialog even though I opened Visual Studio as an administrator.
I'm starting the Web API project directly. That is, I'm not starting a project that uses Web API and therefore need to right click Solution > Startup Projects and set Web API to start. The project is in debug mode. I've cleaned my solution, restarted IIS, and closed and reopened Visual Studio.
Also, I can open other projects, like an ASP.NET MVC app, and the breakpoints work fine there. It's just Web API. Any idea what I am doing wrong?
Restart your computer.
I don't know what the exact cause was but after trying everything else I restarted and now it works.
Also, I had to run it from another project. If I debug the Web API project it doesn't hit the breakpoints but if I debug from the Web UI project (Web API is part of that solution) it works.
edit
And actually that only worked like one time. I ended up including Web API in startup projects and also copying the dll and pdb to c:\mySymbols on each build via post build commands copy c:\path\the.dll c:\mySmbols\the.dll and then going to debug > options > debugging > symbols and adding the path to c:\mySymbols to the list.
edit
Another thing is I was trying to use a custom request validator via
<httpRuntime requestValidationMode="4.5" executionTimeout="300" maxRequestLength="51200" requestValidationType="MyProj.App_Code.CustomRequestValidator" />
and that definitely breaks it. So I had to take that out too (at least until I figure this problem out).
I'm not sure which, if any of these things did the trick but it is working now.

Unable to Debug a Website in Visual Studios

Here is my situation...
I have to maintain a website with multiple applications. We no longer have any of the solution files and the code is deployment code (so it uses DLL's instead of the original classes).
I basically grab the code from the website and stick it in a Visual Studio projects folder (This is generally C# code with Javascript that was originally developed on VS). I then open Visual Studios's 2010 Professional (VS) and open website, using the path in the project folder. I then add references to all the DLL files and if all the includes, images , and css files paths are referenced correctly, I can hit F5 and get the webpage to appear with some functionality. This creates a Project file in the Projects folder which I can then open instead of opening a website.
The problem is that I am unable to debug. If I set a breakpoint, it goes from solid red to outline red upon start of debugging. The standard message is "The breakpoint will not be currently hit. No symbols have been loaded for this document".
I have cleared out the symbols and reloaded.
I have debug = true in all my Web.config files.
I have gone into project properties and set the startup project action to "Start".
Any ideas why I can't debug ? My other projects that I develop from scratch work fine, but it is these projects that I am trying to get working from website files that won't debug.
My goal is to get every one of the Website apps under VS control were I can fix bugs and make improvements. Not very easy when the original source code is no longer available.
Please Help !
Thank You,
Eric
I fought this issue for a half of a day. I'm currently maintaining a website application. What worked for me is going into the project's Property Pages >> Start Options and changing the server to "Use Custom Server". I believe this setting will use IIS and not IIS Express. I started the project and was immediately able to debug.

Visual Studio 2010 gets stuck with solution with MVC3 Razor and Azure

I've a solution with several .dll projects, an Asp.NET MVC3 Razor project and an Cloud project.
If I try to compile the solution with the Cloud project loaded, VS2010 gets stuck in "Buil started".
I have to forcefully close VS2010 killing the process and restart. Then the compiling works good once, the next time it will get stuck again.
If I unload the project and set the mvc project as start-up, everything works (but azure of course).
What could be the problem?
Cheers.
Was it by any chance an ASP.NET MVC project to which you added a CloudService project later on or did you start off with a CloudService from the very beginning?
I was in the former situation and I had no end of problems, like not being able to open property pages or deploying the application. It's not quite your issue, but the following article might help:
http://tomkrueger.wordpress.com/2010/07/27/azure-deployment-issue-after-upgrading-to-visual-studio-2010-and-net-4-0/
As I say, my problems started because I actually added an Azure project to an existing ASP.NET MVC solution and there were some unnecessary settings left over in the web.csproj file.
All I had to do was open web.csproj in notepad and remove all occurrences of the <PlatformTarget> element.
My MVC prjoject was x86 and of course Azure works on x64 only. Even though I had the platform target set up as AnyCPU somehow Azure couldn't quite get along with it.
Maybe cleaning up your project files helps as well.

Visual Studio 2010 Debugging issue

I have a problem with debugging my Silverlight 4 (hosted in ASP.NET MVC2) in Visual Studio 2010. It was working fine until I tried remote debugging. After a lot of hassle I managed to configure remote debugging but it worked only occasionally. So I created a new app and copied my classes one by one, but now I see I cannot debug not only remotely but also "locally" in development server. Breakpoints in Silverlight code says "The breakpoint will not currently be hit. No symbols have been loaded for this document." Strangely enough, if I run my app it will show my previous code results. (It may be relevant, before this problem I noticed that my app doesn't update immediately when I publish to remote web server. So I did the following for all projects in the solution:
//In AssemblyInfo.cs in Properties folder
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.*")]
I'm adviced that it will automatically generate version numbers so, when I publish to remote server it will immediately take into effect, which seems working well.)
However, if I change development server's port number, in the properties page of my ASP.NET MVC app, then I'm able to debug locally (about remote debugging I just gave up). But, it didn't last long; after some updates in my code the problem suddenly reoccurs. I guess development server deploys my app somewhere in a folder per port number, but where? May be, if I delete that folder, will the problem be solved? Can somebody advice me what to do?
There seems to be bug in Visual Studio 2010; see:
silverlight 4, dynamically loading xap modules

Resources