Web server for ASP.NET 5 that works without debugging active - asp.net-core

sorry if this is a stupid question but I don't get it.
So I've created an ASP.NET 5 page using Visual Studio 2015 and DNX.
Out of the box I have these two dependencies in my project.json:
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4"
Under "commands" in project.json I have the following:
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
In the project properties I can change profiles between "IIS Express" and "web" as deployment options. Both are working fine, when I start debug it starts the web server (either IIS Express or the WebListener) and the site is working. If I stop debugging the server stops. The WebListener opens a "dnx.exe" in a command prompt.
This pluggable server layer is really nice, I get the point. But how do I, as a developer setup an easy server where I can make a change to my site and quickly see the changes?
I can of course install IIS and create a site that is pointing to my wwwroot but is that my only option in the ASP.NET world? Can I have the WebListener "started in the background" (without showing me a command prompt with dnx.exe)? I can also start a node server but yet again - it's great that i can but why do I have to when I have the full ASP.NET toolbelt?
ASP.NET 5 has dynamic compilation but I'm not sure how to even test it since my web server is only started when I'm in debug mode.
I know that this is a pre-release but any help would be greatly appreciated.

But how do I, as a developer setup an easy server where I can make a
change to my site and quickly see the changes.
Regardless of the server used, you can use dynamic compilation by Starting the project without debugging (Shift + F5).
Due to architectural reasons, dynamic compilation does not work when starting with debugging (F5) in Visual Studio. This is due the fact that the difference between Shift + F5 and F5 is that in the latter, VS attaches the debugger to the process.
Will this every be supported in the future? That is unclear but right now because VS isn't "smart" enough to handle detaching from process, waiting for dnx to dynamically recompile, and then reattaching to the process. However until now it never had a reason to support such a scenario, so it is unclear if it is just a "it doesn't know how to do it yet" or a "it is impossible to do."
I can of course install IIS and create a site that is pointing to my
wwwroot but is that my only option in the ASP.NET world?
No. You can use any webserver which supports Microsoft.AspNet.Hosting. Today your choices are limited to IIS, IIS Express, and the two experimental servers you linked to but the goal is to enable third parties to develop alternatives by providing an interface that can be programmed against (Microsoft.AspNet.Hosting).
ASP.NET 5 has dynamic compilation but I'm not sure how to even test it
since my web server is only started when I'm in debug mode.
If the web application is running then the server is started. No webserver = no ASP.NET application. I assume by "debug mode" you mean "Start with Debug (F5)". If so then "Start without Debug (Shift + F5)" to fix the problem you're experiencing.
Here is an excercise:
Close Visual Studio (not a requirement but useful to show none of this is VS specific).
Start the web server. The easiest way would be dnx . web run from command line in the project root folder. You could however start IIS Express (should already be configured) or even configure the IIS and start it.
Verify the web server and web application is running by opening it in a browser.
Using notepad or some other text editor, edit a file in the project that would have a visible change or just force an error "throw new NullReferenceException()".
Save the file.
Refresh the browser.
The web application will reflect the change. You may notice a slight delay if you refresh quickly. That is the dynamic compilation to memory occurring.

Related

Running winforms client, does not start iisexpress with the referenced wcf service - under Windows 10. Ideas?

I have a vs solution with 2 projects - WinForms client, and WCF Service.
Since visual studio 2013 to 2019 (I was under Windows 7), every time when I ran in debug the WinForm client, VS automatically was starting the IISExpress in background(I want that!), and my calls from the client were successful, stopping on breakpoints inside the WCF service easy.
Last week, I got new box with Windows 10. Now when I start the client, there is no iisexpress.
The source code is the same and not changed - my co-workers are under Windows 7 and this works for them - same code - we use git as version control.
The only time I see iisexpress is if I do "Update Service Reference" or I make the WCF startup project and run it.
Can you help me identify why this functionality stopped working? Ideas for a fix?
Windows 10, Visual Studio 2019 Enterprise, .NET 4.6
EDIT: I do not have problem running the webservice in IISExpress, when i specifically run it - it works, also on solution level if I set 2 startup projects, all will work. The main issue is that with Single Startup project - thw WinForms client, Visual Studio will not bring up the IISExpress instance. It is only development time issue, and this works for my co-workers.
The solution is in the VS generated (regenerated if missing) user file in the WCF project
.csproj.user
there is property
<AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>
It must be True, but now it is defaulted to False.
The *.user files do not go to version control, and if they are missing VS regenerates them, hence my coworkers had it, and my freshly cloned repo did not.
I'm pretty sure I never touched this file or did any configs like that on the WCF project, my suspicion is that MS decided to start defaulting to False in some version or patch.
WARNING! After changing the option, close/open the entire solution or restart VS.
Disclaimer: I found this solution in the build in VS report problem button leading to a portal with reported problems and solutions. I do not see how to copy link or anything from that Feedback tool, but this is the guy that deserves the credit: 佐々木隆幸
It seems that you want to debug the WinForms application separately regardless of the WCF application. we could set up the project dependencies in the property page of the VS solution.
Then open the SVC file, press F5 to launch the WCF application so that we can add service reference in WinForms application.
Please ensure the below configuration in the property page of the WCF application project.
Besides, if there is something wrong with the IISExpress, we could opt to repair the IISExpress in the below dialog.
On my side, it works like a charm.
Feel free to let me know if the problem still exists.

How to locally run .Net Core 2.0 app in VS Code the same way Visual Studio does with SSL

So, we have a web app we've migrated to .net core, and while it runs fine in Visual Studio 2017, because Visual Studio uses its "launchSettings.json" file to configure how IIS Express will work/launch - I, for the life of me, cannot figure out how to get VS Code to run the project. The problem is, we use HTTPS only and have always just let IIS Express used the self-signed locahost cert to allow this, so when debugging the site locally, we'd always use https://localhost:44300. As stated, this worked fine when entering this url in the launchSerttings.json file for Visual Studio, but VS Code does not use this, and the only answers I can find on this always refer to having to use the Kestrel Server's .Listen() method and used a self-signed cert and password to allow the use of an HTTPS port. 1) this seems just silly that I'd have to add this "test" code to run it locally, because I don't need it when we deploy to Azure, as Azure manages the certs and url for us. 2) Visual Studio 2017 does not need any specification on Kestrel to make this all work. So, I have hard time believing there isn't some extension, or process to achieve the same thing in Visual Studio Code that Visual Studio is doing under the hood to allow IIS Express to communicate with the .Net Core Kestrel Server.
Combing through the all the documentation suggests that the ASPNetCoreModule is what handles this communication for IIS and Kestrel, so, I would hope/guess there has to be some way to configure the web.config file's tag to include something that would make this work.
I've previously used and tried other IIS execution extensions in VS Code, but those focus on elements in the project's web.config to boot IIS which are no longer present in the web.config due to it being a .Net Core app. I had been successfully running the web app with the IIS Express Executor extension before migrating to .Net Core when the web app was a .NET Framework 4.5.2 app
So, the end goal is that I need to be able to go to https://localhost:44300 in the browser, and have our site work, but I don't want to have to add any sort of test-cert into the Kestrel config in the Program.cs or Startup.cs files. If there's no way to do this, then that will be really disappointing considering Visual Studio makes this seem like it should be very simple.
Thanks for the help.
Was able to get this to work using the following steps.
1) Install IIS Express executer in VS Code or any other similiar extension that wraps around dotnet commands
2) Download Process Explorer from https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer
3) Launch Visual Studio IIS Express as you would normally
4) Open Process Explorer (may need to launch as Admin) and locate iisexpress.exe -> VSIISExeLauncher.exe
5) Right click VSIISExeLauncher.exe and click properties then locate the "Environment" tab. Inside the environment tab you will see 2 variables: LAUNCHER_PATH and LAUNCHER_ARGS. Copy both of these variables and values.
6) Next locate the configuration file for the extension you installed in VS code (mine is launch.json inside the .vscode folder in your project root directory). It will likely have an "environment" or "env" section for adding environment variables to the launch arguments. Add the two arguments copied from step 5. These vary from person to person so the value of the arguments will be unique to your machine.
7) Launch IIS-Express from vs code. My particular command for this is "IIS-EE: Start IIS Express Server" but will vary based on the extension you installed. You can hit F1 to launch commands.
Visual Studio itself uses too many tricks under the hood to make you believe it is simple. However, it is not.
I documented all necessary details in a blog post,
https://blog.lextudio.com/how-visual-studio-launches-iis-express-to-debug-asp-net-core-apps-d7fd3677e3c3
And if you follow the steps manually, you should be able to launch IIS Express the same way VS does, and then use that in Visual Studio Code. I know there is some VSCode extensions trying to integrate with IIS and IIS Express, but I do hope those authors spend more time learning such integration and improve their extensions to fully support the scenarios.

WCF Azure 403 error when running locally

I'm stumped. There are several threads out there that reference a similar problem, but not the same one. I'm trying to get a simple WCF service up and running in Azure, but my problem is happening before I even deploy. I'm following this article:
https://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-create-deploy/
Which says to create your project, build the "Hello World" service interface and class, and then start your project locally. I get a 403 error when I try to start my project.
The only step I'm not following exactly is that I don't have a "Start Without Debugging" option (I'm using Visual Studio Express Web Developer), so I just push "Start Debugging."
Why would I get a 403 error on my own machine? I am running Visual Studio as Administrator.
On the WebRole project right click on your .svc (Service1.svc) and choose "Set As Start Page" And then run the project. Make sure to do this on the WebRole project not the Azure Cloude Project.
Is the Azure project the default project or is the WCF Web Role? If it's the role itself, that may be your issue - it's trying to access the root of virtual directory containing the web service versus running the cloud app in the local emulator. If you browse to http://127.0.0.1:81/Service1.svc in a new browser window do you still get the 403?
It seems VS has lost the its project settings. Bring up "Properties" page on the web service in VS. Go to the "Debug" tab. Under Servers/Virtual Path: my configuration was set to just "/". Put the name of your server back in there "/Service1.svc" and it should work from the debugger now. This fixed the problem for me.
The problem went away when I upgraded to VS 2010 Pro. I never fixed it on Express, but after upgrading the problem was gone ... I had the "Start without Debugging" option in the Pro edition, so I suspect that the problem may have been specific to Express.

wcf : Service + Client in same solution, how to debug? I don't want to run 2 versions of VS 2010 at the same time

I have created an application which has a client (WPF) and the Server (WCF), the service is IIS hosted, currently I am having to have 2 versions of vs 2010. One loads the wcf service in IIS and the other in my windows application.
The problem with this is it takes so much resources.
It appears if the wcf service is "NOT" hosted in IIS then I can start two projects at the same time according to this http://msdn.microsoft.com/en-us/library/bb157685.aspx
But what are my other options?
I need to find the best way of being able to compile / run the 2 projects and able STEP INTO each when when in debug, without using too many resources or having more than one vs 2010 open at the same time.
You should be able to debug both from the same instance of Visual Studio if they are in the same solution. When you run your application from Visual Studio, open the Debug menu and choose Attach To Process, you need to attach the debugger to the ASP.NET worker process (aspnet_wp.exe), it should automatically attach to your client.
Open service and client code in VS. Open Debug menu. Attach to process. Hold the Ctrl key and select as many processes as you want to debug using Mouse click.
In your case, you can select the ASP NET worker process depending on the version of IIS and the client process.
The easiest way to debug your WCF service is to:
Right click on project containing svc file.
Select Set as Startup project.
Put a breakpoint on the methods you want to debug.
Breakpoint should be Red.
Make sure your app config file is pointing to the debug WCF service version that's currently running, ex:
http://localhost:12345/MyService.svc
Run your app.
When the app calls that WCF method, it should stop on breakpoint.

Problems with debugging in Silverlight 4 using Out of Browser and WCF RIA Services

With Visual stuido 2010, it's simple to set up SL4 to debug with an out-of-browser installed app. I followed the instructions from here and everything seems to set up fine. Debugging from the browser runs the program just fine, but running from the OOB program gives a different result. After starting, the screen will go blank and then hang forever. I have some concerns that it might be because of some of the technologies that we're using.
Firstly, there's a popup that happens because we're using WCF RIA Services (formerly .NET RIA Services).
"RIA Services will fail unless the silverlight project is hosted and launched from the same web project that contains the RIA Services."
This seems to just be a warning, but I have a suspicion that this warning might be telling me that RIA Services needs to have the .web project as its startup project.
We're also using prism and the error has an odor of a Prism error too. (something loading and then not ever appearing)
Has anyone else had any issues with OOB debugging in SL4? Is anyone else OOB debugging in SL4?
Sorry it's so vague. It's a complicated mess. The only message I see is the italicized popup warning. Then the window (which was previously showing the background of our application) just goes blank
There is currently a known issue with debugging an Out of Browser Silverlight 4 application when using F5 to launch the application from within VS 2010. The question I have is whether or not the application launches without debugging (-F5 or running it from the shortcut)? In the case of using F5, a dialog typically appears with the following error dialog “Unable to start debugging. A fatal error occured. For more details, please see the Microsoft Help and Support web site. HRESULT=0x80070018” and then the application appears to hang. In this case detaching allows the process to continue and then reattaching should allow you to debug the process.
If this is completely blocking or you’re trying to debug code running at startup (like the page startup event), one possible way to get around this would be to put in a call to System.Diagnostics.Debugger.Break, start the program and then attach when dialog pops.
This can be caused by the OOBA install being older than the version you are trying to debug. Remember, Silverlight OOBAs do not automatically update themselves to the latest version of the XAP file that may be available on the server. You have to update them yourself. If you get this error and you have included the auto-update logic in your app, just bounce out of VS, run the app so it auto-updates, then go back in and debug.
Alternately, you can uninstall the app and re-install it. That will ensure you are debugging against the latest VS build.
I ran into this same issue with VS 2008 and Silverlight 3. If I got it, I just jumped out and updated the app then re-ran it in VS and had full debugging.