How do I setup IIS when debugging in Visual Studio 2010? - c#

In Visual Studio 2010 I have created a WebService (WCF) Application and a client to consume said service.
My 3 options as far as what servers to use for debugging are: Visual Studio Development Server, Local IIS Web Server, Custom Web Server.
I know I can't use the VS Development Server if I want my service to be accessible outside of localhost. So I installed IIS (Control Panel>Add/Remove Programs>Add/Remove Features). When I select this option in Visual Studio 2010 it doesn't seem to work. I'm not sure what options I have to setup so that other machines can run the client to consume this service.
By default VS set the Project URL to: http://localhost/MyService. Oh, and I'm working with .svc files (not .asmx) if that makes any difference.

Common problem when you intall IIS after the framework.
Go to your Windows\Ms.Net\Framework\<version> folder and execute aspnet_regiis.exe. It's a commandline tool.

To save having to install IIS you can configure a proxy - such as Fiddler - to redirect certain incoming traffic to localhost.
Because these new requests are "appearing" (via the redirect) from inside your machine, Cassini will respond.
The process is covered in this answer: https://stackoverflow.com/a/4428747/1016183 under "Option #2: Write a FiddlerScript rule"

You can right click on Project and do publish. This will generate the required files for your deploy.
In order to debug your app, you can use the Visual Studio built-in host or IIS.
In your project properties, under Web, you can select "Use Local IIS Server".

Related

Setting up .net project in IIS locally with URL 'application.local'

I am trying to set up a .NET application locally to run with a different alias to 'localhost'. The application has a successful connection to the database and runs correctly when running as localhost.
In some of my projects, I am able to access the application on the browser by writing '.local' after the application name. For example, a project called toysandstuff can be accessed in the web browser with 'toysandstuff.local. instead of having to run it through Visual Studio and localhost.
I have this set up for some of my applications at work but i'm not sure how to configure IIS and Visual Studio to run the project as '.local' instead of using localhost.
Thanks in advance!

How to run the c# exe application without having VS open

I am working with visual studio 2013 in c#. My application contains three project in the same folder: client side, database side and web service side.
When I run the application from within visual studio, it runs very well and all the features of the application are functioning. When I run the exe file located in the bin/debug folder, it runs only when VS is open. If VS is closed it runs only the client side and a message is shown
impossible to connect to the server.
How can I solve this?
When VS is open, it runs the server/web service, and your client. Running it from the commandline will require starting your server and web service side manually, and then starting the client.
If you don't have IIS manager installed you can launch IIS directly from iisexpress.exe.
It should be in C:\Program Files (x86)\IIS Express\iisexpress.exe, so just go ahead and run it.
Then you should be able to run your application.
To start IIS from the IIS manager go to Run (press Windows+R), and type in inetmgr.
This will open IIS manager, from there you can start it (forgive me for not being too specific, I don't have it currently installed. I believe you have a Start button at the side-panel. I hope someone in the comments could chime in or just edit this answer. If not I will install & update later).
After it is on you should be then able to run your executable successfully.
If your command-line can't find inetmgr, see my other answer here.
However if you do want to have the IIS manager you can install it + other IIS features easily:
Go to Computer → Uninstall or change a program.
At the side click on "Turn WIndows features on or off".
Inside "Internet Information Services" have your pick of whatever you want.
When you run in Visual Studio 2013, by default it uses its IIS Express as a webserver. You can set it to use IIS instead. (If you don't already have IIS installed, you'll need to install it using add/remove Windows components etc--google for more info on that if needed. Make sure you drill down to include ASP.NET under the IIS bits and pieces.)
To use IIS instead of the Visual Studio development webserver, right-click the project in Solution Explorer, and click the Web tab:
Select External Host in the dropdown, and enter a URL such as http://localhost/WebApp1. This is the virtual name by which IIS will access the files in your project folder. Earlier versions of Visual Studio included a button to create the virtual directory, but in 2013 you must create it yourself by running IIS Manager:
Enter the same virtual name you use in the project settings, and the physical path of your project:
Finally, right-click the newly created virtual directory and choose Convert to Application.
The website/webservice will now run under IIS, so will be available independently of Visual Studio.

Hosting WCF service created in VS2010 on IIS

I have been through tons of threads and am unable to find the correct answer for my question. I have created a very simple WCF service on my development machine using visual studio 2010. The service works correctly when using VS to host it. I have even had success creating a small c# application to consume this service. However I now need to move this service to IIS on my work's development server. I have tried following several guides online but nothing has worked so far. Any help would be greatly appreciated.
if you are able to execute your wcf service using WCFTestClient successfully and not on IIS
that means problem is in endpoint configuration. I suggest have a look once again endpoint suggestions.
Using Web Deploy to publish from Visual Studio to a remote web server requires additional installation of Web Deploy on the server http://www.iis.net/learn/install/installing-publishing-technologies/installing-and-configuring-web-deploy
Visual Studio generates an output log during the web deploy publish that may have additional information on why it is failing. Sometimes there are permission issues to work through as well http://blogs.iis.net/krolson/archive/2009/11/04/using-iis-manager-accounts-for-web-deployment-tool-msdeploy-delegation.aspx
You can also generate a Web Deploy Package with Visual Studio and manually deploy it to the server http://msdn.microsoft.com/en-us/library/dd465323(v=vs.110).aspx

run my Asp.Net Web application on another machine

How can I run my application on another machine, my team member wants to view the webpage in his computer. He doesn’t want to install visual studio but just wants to see the webpage in the browser.
I am using a Mac book
Publish it to a web server, or have him install IIS on his machine and set it up.. wait. That would be publishing to a web server.
In short, an ASP.NET website needs a web server to run. Usually it's IIS, but if you have Visual Studio, it uses the built-in Cassini web server. Either way, you need to have it in a web server of some kind. You can't just run it as a stand-alone program.
I haven't' done this, but I think you COULD have it running in your computer in Visual Studio and still have him see it. If you run it, you'll see that the address is in the format:
http://localhost/:[some port number]/YourWebAppName
If you have it running in Visual Studio on YOUR machine, your team member MAY be able to access it by changing "localhost" to your PC name. It's worth a shot.
Otherwise, here are a bunch of links to how to publish your site, in case you're not sure.
http://www.google.com/search?q=publishing+asp.net+web+sites&sourceid=ie7&rls=com.microsoft:en-us:IE-Address&ie=&oe=
Create a new virtual directory in IIS
Set the directory root to your project root folder.
allow anonymous access.
Your team member can then access it at http://yourmachinename/virtualdirectoryname
This looks like a good job for IIS express http://learn.iis.net/page.aspx/868/iis-express-overview/
For the majority of things, it's functionally equivilent to using regular IIS 7.5, with the exception that it's easier to start new websites with this. You simply use the command line to start IIS Express, point it to your physical path, set the CLR version, and the port, done!
http://learn.iis.net/page.aspx/870/running-iis-express-from-the-command-line/
There's some instructions for how to do that.

Debug C# web service

I have a web service project and simple test application. I can debug the web service from Visual Studio 2008. However, there exist a real client application, but it is on another machine. ASP.NET Development Server does not allow connections if they are not from localhost, or so it seems. Is there a way to debug a web service, if client application is on another machine?
Edit
The tool that I used is Trace Utility from Microsoft SOAP Toolkit. Further explanation can be found here (works on XP; see continuation story for Windows 7 solution). There was problem with it though. My remote client fetches the WSDL first, and then creates URL based on values in soap tags found at the end of WSDL. So client gets redirected to localhost, which is not good.
I found my problem though, but I'll leave the question open until I find the time to try debugging via IIS.
Install a virtual directory into the IIS on your local machine. If you don't have IIS, install it. Once IIS is installed and configured on your local machine, you should be able to use either the IP or create a dns alias for that IP to access the web service that way.
I'm using SoapUI basic version to fake the SOAP requests to the web service, which is running in debug mode in Visual Studio, from the local computer.
You can use IIS (or Cassini Web server) - for debugging, attach VS 2008 to correct process (for example w3p.exe(IIS6 or greater) or aspnet_wp.exe(IIS 5)).

Categories