In Visual Studio.Net 2005 things have changed quite a bit. For better. But for people who resist changes, they're gonna have some starting trouble. Like the following ones. For me. May be for you as well.
Problem 1:
I want to run my webservices under IIS, not on a developement server with some port (For ex: 4187) which kicks off while debugging (when you press F5).
Solution:
- Right click on the project (there's no really a project there in your solution explorer. Its just a directory structure like C:\...\MyWebSvc\) click Build site.
- Go to windows explorer right click on this directory (MywebSvc) web share it. Go to IIS, Go to the default web site -> MyWebSvc right click properties -> Remove application -> Create application. Say apply. Done.
- Now you can run http://localhost/MyWebSvc/Service.asmx and attach this as webreference to your other project (which uses the websvc) so that your other team members can use this websvc which is now setup on your machine. Make sure you change "localhost" to your machine name, when you web reference it in another project.
Ideally this is exactly what might have to be done on a production web server. I am not sure what the publish site does. Need to check it out though.
Problem 2:
As explained in the Solution above, I am not really comfortable with the idea of having a directory structure for WebSvc or ASP.Net website, without a .csproj.
Can someone tell me what's the purpose and how better to get used to it?
Problem 3:
This is not completely related to VS.Net 2005 but still I would like to put it this way. I have a web service running on my machine, which talks to a SQL server db using windows authentication of my machine. When I run this websvc from my machine all goes fine. Now my other team members run this websvc from their machines, the SQL server login fails. Even I run it from my webbrowser (not in debug mode, not through the dummy dev server) it fails.
Solution:
You have to impersonate the aspnet_wp worker process to use your windows authentication, which can be done by adding the following nodes to your web.config of the MyWebSvc.
<authentication mode="Windows" />
<identity impersonate="true" />
Problem 3.1:
Now with the above problem 3 solved, you have one more minor problem, when you run this websvc from IIS, you want to debug it. So you attach aspnet_wp.exe to your project in the visual studio. But just when you open the SQLConnection (SQLConnection.open), throws an exception
[SqlException: EXECUTE permission denied on object 'sp_sdidebug', database
'master', owner 'dbo'.]
But, if you have handled this exception without rethrowing it, rest of the code works fine without a problem.
Solution:
While attaching the aspnet_wp.exe process, just make sure you've changed the "Attach to:" to work on only "Managed code", just uncheck the "T-SQL code".
Now you won't get an exception while debugging. Check out for more info on this problem.