Deploying WCF webservice to IIS - asp.net

I'm trying to deploy a wcf web service to IIS 7.5. Is there anything special I need to do in order to make this work. I keep getting 404 error when I try and run the web service. I can't seem to pull up the wsdl file either.
These are the steps I've taken
Right-clicked on web service project and published to local folder
Copied contents of publish to IIS server
Setup a new website that points to folder with webservice files
set binding to match web.config binding (port #)
Is there anything I missed or overlooked. Shouldn't I be able to run that web service from IIS and load up the wsdl file directly on the server. When I test in visual studio, it handles the loading of that host program.

Apparently you have to load the .svc file path which I was not doing.

Just to expand on this a little, since this question got me started but there were a couple of extra steps I had to take:
In VS2012 right click on the web service project and select Publish
Publish to file system by selecting a directory to publish to
Copy the folder contents into a folder on the server
In IIS create a new website, its physical path being where you just copied the published contents to.
Set its app pool appropriately (probably .NET 4.0)
The binding port should be the same as in the web.config as should the name. So if you've been working locally and your web.config reads "http://localhost:12345/MyService" then hostname is "localhost" and the port is 12345
You can then browse to the webservice by right clicking on the website in IIS -> Manage Website -> Browse. Click on your service name.

Related

How can I get Visual Studio to automatically attach debugger to web Site not Application?

I have a web application required to run as a Web Site (root application). This is due to it being a multi tenant application that uses the urls sub domain prefix to know which client is accessing it. I create the site in IIS 10 setting the physical path to my Visual Studio 2017 .NET 4.5 MVC application and the site works fine.
I open the web project properties and under Servers choose Local IIS setting and set Project Url to the site I just created in IIS. Visual Studio then forces me to create a Virtual Directory for the Project Url, to save it, which then creates a Web Application under the default web site. You can't set and save the Project Url without being forced to create the virtual directory.
Now when I start debugging Visual Studio attaches to the Web Application not my web site so my breakpoints never get hit. If I manually attach to the w3wp process where the web site is running I can debug. I had this all working fine prior to recently switching to Git causing me to reconfigure things and I can't recall what I did to make it work.
How can I set the Project Url on web properties page without being forced to create a virtual directory? Or how do I make VS automatically attach to the Web Site and not Web App I was forced to create?
This blog might help: How to Debug Your ASP.NET Projects Running Under IIS
If your project is a website and not a web app, then here are the steps to configure it to use IIS when debugging. This assumes you already have IIS set up and hosting your project.
In the solution explorer.
Right-click on your project node and navigate to "Property Pages".
Navigate to "Start Options" item in the left pane.
In the "Server" section make sure "Use custom server" is checked.
In the "Base URL:" field put in the address you have mapped to your project. (Usually the address you put in your hosts file)
I finally discovered that setting the Servers 'Project Url' in the web projects properties page to 'http://localhost/' does not force you to use the 'Create Virtual Directory' to save the changes. You can't even change the default port here without being forced to create a virtual directory.

Routing issues after publish asp.net mvc app

I recently developed an asp.net mvc application that want to publish online. I used the Publish option on Visual Studio to do that.
Apparently this is a common task and there are several tutorials about that. However my case has a different detail that I believe is not allowing me to run the app successfully.
So the thing is:
I have a Wordpress site successfully running at www.somedomain.com
I want my asp.net application to run at www.somedomain.com/myapp
This is what I have done so far:
Uploaded all my app files to httpdocs/myapp folder on the server;
Configured a virtual directory on httpdocs/myapp folder on the server;
Imported the database from my local computer to the remote server;
Changed the connection strings on web.config to point to the database on the remote server;
After this, when I try to access on the browser to www.somedomain.com/myapp I can see that it redirects me to www.somedomain.com/myapp/Account/Login?ReturnUrl=%2Fmyapp%2F but shows the 404 error (Page not found) with the layout of my Wordpress site. So it looks like it is running the Wordpress site, instead of the asp.net app on that folder.
are you using IIS?
you need to create an application instead of a virtual directory
otherwise it will not treat the sub folder as an application and will follow parent folder’s web.config and other settings

HTTP Error 500.19 - Internal Server Error 0x80070003 Cannot read configuration file

I'm getting the above error when I publish my application and move it from development to production server. Below are the error details.
Detailed Error Information
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070003
Config Error Cannot read configuration file
Config File \?\C:\inetpub\wwwroot\WorkmenCompTest\web.config
Requested URL http://localhost:80/wictest
Physical Path C:\inetpub\wwwroot\WorkmenCompTest
Logon Method Not yet determined
Logon User Not yet determined
This website used to work previously but recently the published version stopped working due to this error. As far as I can tell, the only change was installing iTextSharp and iTextSharp xmlworker through nuget.
I have tried, without success:
giving modify permission on the site folder to Everyone
checking the web.config file, and using an older version of the web.config file (from when the site worked).
uninstalling iTextSharp and iTextSharp XMLWorker
The project still runs without issue from Visual Studio.
This is solved. The error was caused by the folder name not matching the path for the virtual directory. Oh wow I feel dumb.
Check the applicationhost.config file under - .vs\lpsWeb-UI\config folder of your application root.
Under sites section of the config file check what the physical path points to.
If you modify those you should be able to fix the issue.
This is because of different physical path in the IIS.To change the physical path of application content
You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
User Interface
To use the UI
Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
In the Connections pane, expand the Sites node and click to select the site in which your application runs.
In the Actions pane, click View Applications.
On the Applications feature page, select an application from the list and then click Basic Settings in the Actions pane.
In the Physical path box, change the path of the application content.
Click OK.
DefaultAppPool application pool runs under the Network Service account. This account is local to the computer and this account does not exist on another computer. Make sure that you configure the DefaultAppPool application pool to use an account that is a domain user. Then, you can use the same account on the WorkmenComp file server. Alternatively, you can create a workgroup account on the WorkmenComp file server.
I am getting this HTTP Error 500.19 error when I am giving physical path as Z:\App_Live in IIS
Instead of using z:\ ,
I used network path \\server\share\live_folder in the IIS physical path – something like this \\server\share\wwwroot\inetpub\wwwroot
Also you may need to specify username/password in "connect as".

Questions about copy IIS config files to another server

I have several asp.net web services is running in IIS. Now I want to move to another server in all exactly same IIS setting and using same web services. I know about copying a IIS config files(ApplicationHost & administration) to new server remotely but do I also need to copy all asp.net files to new server as well? If yes then must the asp.net files be in the same file path directory as the current one(D:\Website) for IIS in new server to be able to recognize it?
Yes, you would need to copy the ASP.NET files as well.
It is not necessary to put them in the same file path directory. Whatever directory you put them in, ensure your IIS Website Settings point to that directory and you have setup the same set of permissions etc. on it.
e.g. You could have had a website on c:\site on one web server. you could move the website files onto another web server and put them on d:\newsite\ and change the Website Directory Path in IIS Manager to point to D:\newsite\ directory.

ASP.NET webapplication deployment - with domain / server name access

I have deployed my ASP.NET web application on IIS (windows 2008 server). I have created a virtual directory (named TestApp) and all the users on local area network are accessing it with the following URL.
http://"SERVERNAME"/TestApp/Default.aspx
My client wants that, it should be accessed as following URL
http://"SERVERNAME"/Default.aspx
There is single application deployed on the server.
Could you let me know how can i implement this thing??
Instead of adding a virtual directory on the existing site, you need to add a new web site
Create a Web Site (IIS 7)
In fact, it's fairly simple.
Remove your current app, including all files and settings in IIS (i.e.: delete everything).
Run the deploy wizard again, BUT be carefull of the path that it's given to your application: by default, you should see "http://SERVERNAME/TestApp/". Remove "TestApp". The wizard will show you a warning message, just continue.
Finish the wizard as usual, and voila!
I did this 2 or 3 times yet.

Resources