Tag Archives: ASP.NET

OmniSharp – Making cross-platform .NET a reality, and a pleasure

In case you missed it, make sure to read Announcing .NET 2015 – .NET as Open Source, .NET on Mac and Linux, and Visual Studio Community because there’s been some big stuff going on.

Here’s the summary of the .NET 2015 Wave of awesomeness.

The other thing I wanted to talk about is a newly organized group of technologies called OmniSharp. Just to be sure there’s no confusion, OmniSharp isn’t a Microsoft project. While there are two Microsoft folks on the team of 8 or so, we are working on it as community members, not in an official capacity.

I “launched” this project in my talk at the Connect() mini-conference in New York a few weeks back. You can watch that video here on Channel 9 now if you like. However, the technologies around and under OmniSharp have been around for years…like over a decade!

As a team and a community we pulled together a bunch of projects and plugins, got organized, and created https://github.com/omnisharp and http://www.omnisharp.net. Jonathan Channon has a great overview blog post you should check out that talks about how Jason Imison created OmniSharpServerwhich is an…

HTTP wrapper around NRefactory allowing C# editor plugins to be written in any language. NRefactory is the C# analysis library used in the SharpDevelop and MonoDevelop IDEs. It allows applications to easily analyze both syntax and semantics of C# programs. It is quite similar to Microsoft’s Roslyn project; except that it is not a full compiler – NRefactory only analyzes C# code, it does not generate IL code.

OmniSharp runs as its own process and runs a local Nancy-based web api that your editor of choice talks to. If you have an editor that you like to use, why not get involved and make a plugin? Perhaps for Eclipse?

We now have plugins for these editors:

  • Sublime
  • Brackets from Adobe
  • Atom from GitHub
  • Emacs
  • Vim

And these work on (so far) all platforms! It’s about choice. We wanted to bring more than autocomplete (which is basically “I think you typed that before”) to your editor, instead we want actual type-smart intellisense, as well as more sophisticated features like refactoring, format document, and lots of other stuff you’d expect only to see in Visual Studio.

We also brought in the Sublime Kulture package which gives Sublime users support for ASP.NET 5 (formerly ASP.NET vNext), so they can launch Kestrel (our libuv based local webserver), run Entity Framework migrations, and other arbitrary commands from within Sublime.

.NET in Sublime, in Vim, in Brackets, in Atom, and everywhere else, cross-platform

Here’s OmniSharp running in emacs on my Windows machine. The emacs setup (here is an example) is a little more complex than the others, but it also gives emacs folks an extreme level of control. Note that I had to launch the OmniSharp server manually for emacs, while it launches automatically for the other editors.

image

Here is an ASP.NET MVC app running in Sublime. The Sublime OmniSharp package output can be seen in the debug console there (Ctrl+~ to see it).

image

OmniSharp is in very active development. We are looking at bringing in Roslyn, using the new ASP.NET Design Time Host, and improving robustness. It’s not perfect, but it’s pretty darn cool. There’s lots of details in Jonathan’s writeup with great animated gifs showing features. Also note that we have a Yeoman generator for ASP.NET that can get you started when creating ASP.NET 5 apps on Mac or Linux. The yeoman generator can create Console apps, MVC apps, and NancyFx apps.

You can get started at http://omnisharp.net.  See you there!

via: http://www.hanselman.com/blog/OmniSharpMakingCrossplatformNETARealityAndAPleasure.aspx

How to: Specify a Port for the Development Server

In Visual Studio, you can select from several Web servers: IIS, IIS Express, or the built-in Visual Studio Development Server. For information about the differences between these servers, see Web Servers in Visual Studio for ASP.NET Web Projects.

By default, when you create a Web site or a Web application project in Visual Studio that uses IIS Express or the Visual Studio Development Server, a port is selected for the project. For example, if you are testing a page named MyPage.aspx, when you run the page using IIS Express or the Visual Studio Development Server, the URL of the page might be the following:

http://localhost:31544/MyPage.aspx

If you want to run the project on a specific port, you can configure the Web server to do so.

NoteNote
Visual Studio cannot guarantee that the port you specify will be available when you run your file-system Web site. If the port is in use when you run a page, Visual Studio displays an error message.

To specify a port for a Web site project that uses IIS Express

  1. In the Tools menu, select Options and then General.
  2. Make sure the Always Show Solution option is selected.
  3. In Solution Explorer, right-click the project name and then click Remove. This removes the project from your solution, but does not delete the corresponding files on disk.
  4. Click OK.
  5. In Windows Explorer, navigate to the IIS Express ApplicationHost.config file. By default, this is located in the following folder:%systemdrive%:\Users\<username>\Documents\IISExpress\config
  6. Open the ApplicationHost.config file in a text editor such as Notepad. In the sites section, search for the Web site name.
  7. In the bindings section for the Web site, change the port binding.The following example shows the bound port set to 40955.
    <site name="WebSite1" id="1">
       <application path="/" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="C:\WebSites\WebSite1" />
       </application>
       <bindings>
          <binding protocol="http" bindingInformation="*:40955:localhost" />
       </bindings>
    </site>
  8. Save the ApplicationHost.config file and close the text editor.
  9. In Solution Explorer, right-click the solution, select Add, and then select Existing Web Site.
  10. In the Add Existing Web Site dialog box, make sure that the Local IIS tab is selected.
  11. Under IIS Express Sites, select the site for which you have changed the port number, and then click Open.The project name contains the URL with the new port number for the Web site (for example, http://localhost:40955/). If the solution was created at the same time as the original Web site project, the previous port number will still be part of the solution name (for example, localhost_40954).
  12. To update the solution name to reflect the new port number, in Solution Explorer right-click the solution name, select Rename, and then specify a new name.
  13. On the File menu, click Save All.
  14. To verify the change, press CTRL+F5 to run the project.The new port number appears in the address bar of the browser.

To specify a port for a Web site project that uses the Visual Studio Development Server

  1. In Solution Explorer, select the project name.
  2. In the Properties pane, set Use dynamic ports to False.This enables editing of the Port number property.
  3. Enter a port number for the Port number property.
  4. Click outside of the Properties pane. This saves the property settings
  5. To verify the change, press CTRL+F5 to run the project. The new port number appears in the address bar of the browser.

To specify a port for a Web application project that uses IIS Express

  1. In Solution Explorer, right-click the name of the application and then select Properties.
  2. Click the Web tab.
  3. In the Servers section, under Use Local IIS Web server, in the Project URL box change the port number.
  4. To the right of the Project URL box, click Create Virtual Directory, and then click OK.
  5. In the File menu, click Save Selected Items.
  6. To verify the change, press CTRL+F5 to run the project.The new port number appears in the address bar of the browser.

To specify a port for a Web application project that uses the Visual Studio Development Server

  1. In Solution Explorer, right-click the name of the application, and then select Properties.
  2. Click the Web tab.
  3. In the Servers section, under Use Visual Studio Development Server, select Specific port.
  4. Change the port number.
  5. In the File menu, click Save Selected Items.
  6. To verify the change, press CTRL+F5 to run the project.The new port number appears in the address bar of the browser.

via: http://msdn.microsoft.com/en-us/library/ms178109.ASPX

Troubleshooting badly behaving IIS application pools

There are many reasons why an application pools’ worker process (W3WP.exe) could be behaving badly.  The best approach is to capture some memory dumps during the problem situation and then analyze them.  The problem with that is the root cause is not always obvious, even after many hours of analysis and investigation.

An alternative to memory dump analysis, or maybe a prequel, is to capture and analyze the behavior of the worker process.  One of the simplest actions to monitor the application pool is to open up Task Manager and look at the PID of the W3WP.exe process, as illustrated in Figure 1.

Figure 1, the w3wp.exe PID

Write down the PID in the morning and then come back a few times during the day to see if the process is restarting.  When/if the worker process restarts, it will get a new PID.  If you do notice that the worker process is being restarted, consider using the “Generate Recycle Event Log Entry” features available via the Advanced Settings… window for the given application pool.  Figure 2 shows the default settings on a Windows Server 2012 IIS 8 machine.

Figure 2, The Generate Recycle Event Log Entry settings

During the troubleshooting phase you might consider enabling all of the attributes to be certain that you capture as much information as possible.  However, once you complete your troubleshooting phase, consider disabling the ones you do not find useful in
your environment.  The description of these attributes are described in the below bulleted list.

  • Application Pool Configuration Changed – Event is logged when the application pool recycles due to a change in its configuration
  • ISAPI Report Unhealthy – Event is logged because an ISAPI extension has reported itself as unhealthy
  • Manual Recycle – Event is logged when the application pool has been manually recycled
  • Private Memory Limit Exceeded – Event is logged when the application pool recycles after exceeding its private memory limit
  • Regular Time Interval – Event is logged when the application pool recycles on its scheduled interval
  • Request Limit Exceeded – Event is logged when the application pool recycles after exceeding its request limit
  • Specific Time – Event is logged when the application pool recycles at a scheduled time
  • Virtual Memory Limit Exceeded – Event is logged when the application pool recycles after exceeding its virtual memory limits

Once configured, you would begin seeing events logged into the System event logs on the IIS server.  Figure 3 shows 3 logged events which caused a recycle of the application pools’ worker process.

  • Event ID 5186, 5080 and 5079
  • Useful link to IIS Application Pool Recycling event ids

Figure 3, IIS Application Pool Recycling events

The recycling of an application pool is in many cases nothing to be alarmed about.  However, this is a place to analyze and track when you are experiencing some unexpected behavior.  At the same time, if the recycling is happening multiple times throughout the day, you should look into what is causing it to happen as the recycle does have a customer impact.  Read this article which digs deeper into appDomain recycles and the impact they can have here.

via: http://blogs.msdn.com/b/benjaminperkins/archive/2013/07/01/troubleshooting-badly-behaving-iis-application-pools.aspx