How to host a webApp with a Web Service - asp.net

I have an ASP.NET web application that does some calculations using a Web Service. I have two questions about hosting it locally on my machine through IIS.
First, Do I need to host the two projects, the Web App and the Web service ? I have tried to host the web app but when I tried to run it was not able to connect to the web service.
Second, how would I make this web App accessible to the people within the company network only?
Thank you!

Steps:
1.) Create web service.
2.) Paste your web service bin ==> Debug Content in IIS if already set it up(IIS).
3.) Set Framework in application pool(IIS).
4.) (Click Web Service Site Created(IIS)) == >Set up Browsing Directory to enable.
5.) select .asmx file(right click) ==> Browse.
6.) Web Service is already running.
7.) Get the Link of your Web Service copy and paste into (9 step).
8.) create vb.net/c# project.
9.) Right Click references tab of your vb.net/c# Project ==> Add Service Reference paste web service url in address textbox == > Go.
10.) Create service reference name ==> ok.
11.) you have your web service now at your project.

Related

How to host asp.net webapi project with the current build on IIS

I want to host my ASP.Net Web api project on IIS for local development. I have an angular UI that wants to access this API. So for this reason I don't want to run my ASP.Net project all the time, if it were running on IIS would be better. I read many articles but none of them seemed to resolve my problem.
I know how to publish my project and then host the published version of the current build but what I don't want to do is having to do a publish every time I build just to test my code.
If I am not mistaken there is an option for deploying a new version of my project with every build. Again I don't want it to be production ready, I only need it for local development to test my API.
When I was using the publish > host currently published version on IIS the application was running.
When I was configuring IIS to point to the application folder where the solution is found as well (that is what I saw in an article about configuring IIS) I got: "HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
The solution is:
Go to IIS Manager in windows
On the left hand side of the panel, right-click -> add new website
Add a Site name that you like
Set up a Physical path, that should point to your project folder (so not where your solution is but where your ASP.Net project is)
Add a unique port that number that you make sure you are not currently using
Add a host name, and register it in the C:\Windows\System32\drivers\etc\hosts file with your local ip address

how to access my temporary second web site by using URL (or IP) of my primary web site

I have an ASP .NET web app site (ie. www.first.com).
I also have a temporary 2nd ASP .NET web app project.
I want to access 2ND site from the Internet by using somehow the URL of the 1ST web site.
How do I set up IIS to do this?
For example, can I have "www.first.com/second" browse the default.aspx of the 2ND web app project?
Host is Windows Server 2016 Pro on my Azure VM.
How about https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/virtual-directory-setup-instructions
In this case your second app become another app under the main one.
You could also use add nested application in your primary application. You could firstly publish your application to the Azure VM's disk. Then you could use IIS's managment console to add the nested application as below:
More details, you could refer to below steps:
1.Open the IIS management console and right click your primary application.
2.Select application or virtual directory and select the web application physical path.
Result:

How to stop WCF Service project from being hosted automatically while debugging

I have Asp.Net solution that contains few WCF Service projects. Every time i run the application in debug mode, i can see that my services being hosted on ASP.Net Development Server. I just have single project in the start up.
Is there a way i can avoid this without removing these WCF Service projects from the solution?
To reproduce the situation. Create one ASP.Net project and add several WCF Service projects. Press F5 and you will see the WCF service projects being hosted on local development server.
This is what i have tried so far:
1) Project->Properties->Don't open a page. Wait for a request from an external application. I selected this option but it still hosts the service.
2) Unchecked ASP.NET in Debuggers selection. It still hosts the service.
Try right click the WCF project and go to the WCF Options tab.
Uncheck the Start WCF Service Host when debugging another project in same solution.
Is this what you are looking for:

Publish ASP.NET MVC 3 (Razor) app onto remote server running Windows Server 2003 with IIS 6

I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that runs fine on my local machine with IIS Express. Now I'm trying to publish it to a remote server that is running Windows Server 2003 and IIS 6 and has just been upgraded to .NET Framework 4.0.
I was able to successfully publish all the files to the proper directory on the remote server using Visual Studio 2010's Publish dialog (Publish method: FTP), and I've followed the instructions for including all the DLLs needed to run ASP.NET MVC on a machine that doesn't have it installed, but now I'm pretty much stuck.
The first issue is that I don't have access to the remote server's IIS. I may be able to get the hosting company to add a virtual directory or change a setting, but I'm not sure they know what they're doing, and at the moment, I wouldn't know what to tell them anyway.
The second issue is that I need my web app to live inside an existing site (the web app is basically a protected members area of the main website). So, pretend the main site is http://www.foobar.com. I'd like my web app to be accessed by entering the URL http://www.foobar.com/members.
Questions
Is it possible to publish my web app without access to the remote server's IIS?
If not, what exactly do I need to tell the hosting company to add or change in IIS?
Do the settings under the Web tab of project properties affect publishing or just local debugging? At the moment, I have it set to use IIS Express, and the Project URL is "http://localhost:7373/". Do I need to change these?
Given that the remote server is running Windows Server 2003 and IIS 6.0, is it possible to use Web Deploy or am I limited to FTP?
If I can use Web Deploy, what do I put for the Service URL? All I have right now is a URL in the format of ftp://www.foobar.com/www and a username and password.
If I need to use FTP, what steps do I need to take to get the app working once the necessary files have been uploaded to ftp://www.foobar.com/www/members? I'm not worried about database, security certificates, registry, GAC, etc., I just want to know the steps necessary to get the home page of my web app to come up when I put http://www.foobar.com/members.
Have you had a look at this article by Scott Hanselman?
In addition to that article, please read the following thread on StackOverflow on pretty much the same environment as yourself.
Edit
Your first step should be to get the hosting company to set up the virtual directory with the following parameters (IIS 6):
ASP.NET Version: 4.0.30319 (or later)
Local Path: [root ftp path for main website]\Members
[ ] Script source access (unchecked)
[x] Read (checked)
[ ] Write (unchecked)
[ ] Directory browsing (unchecked)
[x] Log Visits (checked)
[x] Index this resource (checked)
Application Name: Members
Execute Permissions: Scripts only
Application Pool: ASP.NET 2.0

How can I deploy an ASP.NET web on IIS without creating a separate site?

I've created an ASP.NET web tool that will just be used by a few people in my team where I work. I deployed it on our internal (Win2k, IIS6) web server by creating a new website in IIS and assigning it port 81. Users can access it with an address like http://myserver:81. All the other web stuff on the server is classic ASP and is accessed with addresses like http://myserver/path/to/myfile.asp.
This works fine, but I'd rather set it up so that the ASP.NET app is not configured as a separate web site, and is just accessed via a folder path like the classic asp stuff. That way users wouldn't have to specify the port and we wouldn't get the overhead of an additional web site for every little ASP.NET app we make.
The problem is when I build the site in visual studio, it compiles all the .cs files into one .dll file, and if I just copy everything over to some folder on the server and type the address of the .aspx file, it can't seem to access any of the c# functions in that .dll file.
Can an ASP.NET app be set up like this, short of writing all C# code within the .aspx files?
Assuming you want your application to run as a subfolder of a website bound to http://192.168.1.1:
Build your website, and drop it into a subfolder called "A" in the root website folder
Verify that Network Service and IUsr accounts have read access (at least) to your Subfolder
Verify that the application pool serving the website is using the same version of the .NET Framework as your application (Probably 2.0 if you're using IIS 6)
Verify that the application pool is running under the Network Service Identity
Right click the folder in IIS, and convert it to an application
Make sure you setup an adequate default file on the application, such as default.aspx
Access http://192.168.1.1/A/ and your application should load
Note: All applications in the website must run the same version of the .NET Framework

Resources