Starting a ASP.NET restful webservice on IIS - c#

I have developed a restful web service using ASP.NET, and while using the Visual Studio environment, it worked like a charm with IIS Express. The service itself is a complementary feature and will have to run on every machine on which our product is installed.
I have therefore created a new directory webservice, which holds the web.config and the Global.asax file, as well as a directory bin, which holds the RestulWebservice.dll file.
I then have setup a new web page on the IIS, rooting at C:\inetpub\wwwroot. The web page itself is hosting a web application, based in C:\inetpub\wwwroot\RestfulWebservice (which holds the files described above).
However, if I startup the IIS and visit http://localhost:80/RestfulWebservice, all I am getting is an error 403.14, stating that I may not inspect the contents of this folder unless I allow IIS to do so. If I choose to allow this, I am simply presented with the contents of the folder, not the service itself.
If I try to access a resource of the restful web service directly (i.e. http://localhost:80/RestfulWebservice/Home, I get a direct 404.0 error, telling me that the resource does not exist)
What am I doing wrong here, it can impossibly be this hard to get a compiled library ASP.NET web service to run on the IIS, it works like a charm on IIS express.

c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

Related

How to fix the 500 internal server error when deploying a web application to an ASP.NET framework VM on google cloud?

I am trying to deploy a simple ASP.NET web application over the Internet, using the google cloud platform. I followed the tutorial on this page : https://cloud.google.com/dotnet/docs/getting-started/hello-world (I uploaded a slightly more complex app though). So basically everything went well from the creation of the ASP.NET framework virtual machine to the deployment from my computer to the VM since I've been able to reach for the web app home page through the VM IP address.
Starting Web deployment task from source: manifest(C:\Users...\obj\Release\netcoreapp2.2\PubTmp\myApp.SourceManifest.xml) to Destination: auto().
Updating file (Default Web Site\MyApp.deps.json).
Updating file (Default Web Site\MyApp.runtimeconfig.json).
Updating file (Default Web Site\web.config).
Successfully executed Web deployment task.
Problem is that the home page won't display as it did when I would deploy it locally (with IIS express) but rather throw an
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
I found some interesting subjects raising the same issue :
Deploying website: 500 - Internal server error : suggests to enable detailed errors and/or to change a few lines in the web.config file but I do not have a web.config file at my side of the process in my project (only a Startup.cs which does some of the work) and I cannot manipulate the one in the google virtual machine.
I noticed that before uploading the web app to the VM, the output displayed errors similar to these : https://github.com/dotnet/sdk/issues/1897 (message NETSDK1041) so I thought that the discrepancies between referenced/platform assemblies might be the origin of these errors but then, why wouldn't they impact the local deployment of the web-app too ?
I would like my web application to run on google cloud's VM (based on the generic Google Compute Engine ASP.NET framework), the web app is 'correctly' deployed to the host VM but raises a wild 500 - internal error. Anybody has any idea as to how I could at least identify the source of this error ? (Helping me find the web.config would also help greatly, I understand that everybody has this file somewhere, but I can't find it and don't have a clue on its whereabouts because I just used a random template MVC application on Visual Studio Community 2017 which did all the configuration work

Is it possible to persist session data on IIS Express cross different web projects in Visual Studio

We have an existing ASP.NET Web Forms application which contains many different Visual Studio web projects. All web projects were configured to run under same localhost root path (e.g. http://localhost:12345/main/projectspecificname). We use state server to keep the session data and cookieless is set to false.
This approach worked OK when using VS2012 and ASP.NET Development Server. However when we tried to run same application from VS2015 + IIS Express we found it cannot keep session data when redirects happen between different web projects. For example, when calls Response.Redirect("project2/index.aspx") from project1/login.aspx, from Page_Load event in project2/index.aspx I see the session variable lost all the data carried on it(i.e. Session.Count == 0). Same debug procedure against ASP.NET Development Server returns a count greater than 0. Again, for IIS Express, all different projects were configured to use project URL like http://localhost:12345/main/projectspecificname.
I have searched a bit and found this SO post IIS Express doesn't keep session data which mentioned a solution as to disable Browser Link in VS, but that doesn't work for my case. I am just wondering whether we missed some settings or this approach won't work for IIS Express. Any help is appreciated.
I found a solution to this problem. Looks like IIS Express treated these projects as different web applications so session initialized every time it tried to connect to another project.
By default Visual Studio creates an <application> node holding information like virtual path, application pool and physical path under <site> section in applicationhost.config for each web project. Remove <application> nodes for the web projects you don't want to run as a separate web application will make them run under same web site as per their physical path indicate.Therefore, session data can be correctly maintained between pages from different projects as they are considered in the same application now.

Web API routing in IIS 7.5

I am attempting to publish our web api to IIS 7.5. I have it deployed as an application "api". I am able to successfully deploy the application and it runs. I can access it at /api/api/. I believe this was due to having "api" in the routing config of the api controllers as well as having it hosted in the "api" application in IIS. I have removed the "api" portion of the route path in web api and it works correctly if I launch it from visual studio. I would like to access it from /api instead of /api/api but IIS doesn't recognize this change. What could be causing this in IIS? I am fairly new to IIS and I have googled around but I have not found anything useful.
TL;DR
I updated routes in my web api application but IIS is not recognizing those changes.How can I force IIS to update?
After playing with this for some time I found that the problem was that I pointing the physical directory of IIS to the deployment package from VS and because I was building the project directly on the machine. This caused VS to quietly fail when it couldn't update the files because they were locked by IIS. After deploying to a new path and then replacing the contents of the application the new routing works as expected.

Visual Studio 2013 web forms project (.NET 4.5 and above) fails when deployed to hosting service. Runs locally

I've recently been working with ASP.NET again and decided to create a small ASP.NET project in a subfolder on one of my websites. I'm using Visual Studio 2013 and created the project using the ASP.NET Web Forms Application template. After creating the project, I left everything at the default, verified that it would build locally, published it to a folder on my system and then copied the published files via FTP to the subfolder on my site. When I tried to bring it up in my browser, it failed with the code ERR_CONNECTION_RESET. This told me that the host was seeing something there, otherwise it would have gone to my site's main 404 page. Chrome also refused to load the other pages within the deployed template. I did set the folder as an application in IIS after getting another error about forms authentication but that didn't have any effect.
I was able to successfully re-deploy an old ASP.NET site created with .NET 4.0 in VS2010. I was also able to deploy and load a project created in VS2013 / ASP.NET 4.5.1 with the ASP.NET Empty Web Application template.
I finally finally get the Web Forms template to work by doing the following -
Created a basic Default.aspx page with no master page.
Created a basic web.config file (copied from another new empty
project)
Commented out the following lines in the Application_Start function of Global.asax
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterOpenAuth();
RouteConfig.RegisterRoutes(RouteTable.Routes);
At that point, the project ran on the host with no problem. I then restored the Default.aspx and Web.config files and the project again failed, even with the Global.asax lines still commented.
I also changed the SessionState mode to "Custom" as suggested in the web.config file and this made no difference.
My question at this point is this - Has anyone else deployed a .NET 4.5.1 Web Forms app designed from the VS2013 template to a shared hosting service and is there something that you have to do to get it to work?
I'm fairly satisfied at this point that I can use the empty web application template and build things from scratch but I'd like to know if anyone else has run into this and what they did.
Thanks.
ERR_CONNECTION_RESET sounds to me like you were having some kind of Internet connectivity troubles, or your server was having some sort of Internet connectivity trouble. If it's working fine now, probably nothing to worry about.
Has anyone else deployed a .NET 4.5.1 Web Forms app designed from the VS2013 template to a shared hosting service and is there something that you have to do to get it to work? Yes, lots of people have done that.

C# web service Deployment to IIS Server

I have created a web service using C# and I have installed IIS Server 6.0. When I am running web service directly in project its working well.
Now I want to deploy this service on my system's IIS Server so that my LAN partners can use it. How should I do that? And I want to change default port number of IIS too, how can I do that?
To run your web service under IIS, setting up a virtual directory is pretty straightforward.
If you're looking to test publish a build, the web deployment project is the best option, you can do it from the command line and in VS.Net, it enables a "Publish" right-click option.
Your web service endpoint is your .asmx file (no .cs file required in your deployment), and the DLL in the bin folder contains the code that you wrote for your webservice.
SOAP, WSDL, Namespace are all handled by IIS and ASP.NET.
In simple words:
create a project of type "ASP.NET Web service".
Select "HTTP" from location dropdownlist (indicates that the file should be placed on a web server)
After Develop your web service, Add web references, select "browse UDDI Servers on the local network" option if you want to share the web service among different computer. Enter the source .asmx file URL and click "Go".
Select "Add References" to add your reference name for web service, by default is "localhost", you can give it a name.
Declare a reference for your web service in your .aspx file.
You can try run your application in other PC.

Categories

Resources