How to point the website to a particular Folder in IIS - asp.net

I am a beginner in web development. I am not sure how to tell the website to point to a particular folder in IIS. I have ASP.Net MVC - 5 Web Application.
Step 1. Bought a domain/url.
Step 2. Bought a server with IP Address (Windows Server).
Step 3. Pointed the url to the Server's IP Address..
Step 4. Have locally published my webapp code from visual studio. And now I need to paste this code on the server.
Question 1. Now where do I need to put the code in server so that the IIS will host it and anyone visiting that website will hit that folder which has all my website code. I am a beginner please guide me.
Question 2. In future I will put another web site code too on that same server, let's say the URL for new web app is xyz.com. How to tell xyz.com to go to the other folder dedicated for it, and not the older one. Basically, How multiple web site hosting will work?
PS: using remote desktop client. I am able to log in to my windows server.

In IIS, by default one site is created which points to "%SystemDrive%\inetpub\wwwroot" and it has a default HTTP binding where it listens to all incoming requests on PORT 80.
Now in your scenario, you have several options. You can either create a new site and point it to the folder where your published code resides or you can edit the existing site configuration to point to the folder where your app resides. Below instruction is to edit the exiting site configuration:
Launch IIS Manager
Right click the Default Web Site and navigate to Manage Website > Advanced Settings
Under Default settings, update the physical path to point to the folder where the app resides.
NOTE: you will have to give permissions to IIS_IUSRS account on
the folder or run the application pool under the context of a user
which has necessary privileges to read from the directory.
FYI, all the IIS configuration resides in applicationhost.config file which resides in C:\Windows\System32\inetsrv folder.
Inside this file, the site configuration is present under the <sites> xml tag.
Here is an exmaple:
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
</sites>
I wouldn't recommend editing the file directly as it can be prone to human errors. I would recommend to use appcmd commandline utility instead.
You can leave the binding as it is. As per the above binding, all the requests that hits port 80 on the server will be handled by the web app. If you intend to add HTTPS support, then you will have to purchase a SSL certificate and then add a SSL Binding for your site.

The website usually goes in the C:\inetpub\wwwroot folder. That is the default IIS root directory. You can change this if you please in the IIS settings mentioned below.
For the second website, you can add another folder anywhere on the server, technically. In IIS: Right-click Sites -> Add Web Site and then set the physical path and other details to your new site's file directory.
Edit: I missed the DNS part. You just have to point the DNS name through your hosting company to the IP and port of your website. For the second site, just put it through a different port and point to the same IP and that port. There's other ways to do it, however: Multiple domains on same webserver

Related

ASP .NET served on local ip not localhost

On a ASP .NET project, as I needed to see my local work on my phones, I wanted to switch from "localhost" to local ip.
I changed applicationhost.config :
after the existing localhost nodes, adding :
<binding protocol="http" bindingInformation="*:64645:192.168.XXXX" />
<binding protocol="https" bindingInformation="*:44314:192.168.XXXX" />
But nothing works, when building and running the project applicationhost.config is overwritten, those two lines disappear and back to initial state, indeed runs localhost:44314
I use JetBrain IDE
If you have any clue, merci !!!
From your description, I assume that you have hosted your Asp.Net site on the IIS web server and you would like to access the site in your local network using a mobile device. (Please correct me if I misunderstood something).
In the case mentioned above, you could refer to the steps below.
Open the IIS, and select your site. Go to the bindings.
Add new HTTP binding. Keep the Hostname empty. Select the desired port. Keep the IP address All unassigned.
Go to Firewall settings. Add a new inbound rule. Add the port that you are using for your site. Complete the steps by clicking the Next button.
Restart your site in the IIS.
Now you could access the site using [IP Address]:[Port Number] within your network using any device.
By referring to the same steps you could configure the HTTPS binding.

What is the worker process account in machine.config if <processmodel autoConfig="true">?

I'm trying to run a website on localhost using IIS in Windows 10.
I'd like to be able to access the website through another pc in the lan using a local ip address and port. I just started debugging the application in visual studio 2015, I could run
<binding protocol="http" bindingInformation="*:51258:localhost" />
but using
<binding protocol="http" bindingInformation="*:51258:192.168.1.213" />
causes an "Access Denied" popup in visual studio
I've followed the steps in
https://support.microsoft.com/en-sg/kb/894433
but was confused with step 7 i.e.
7. Add the worker process account that is configured in the processModel element in the Machine.config file
I was able to locate the machine.config file but the process model is set to autoconfig=true i.e.
Do I have to setup a custom account or is there a default worker process account that I'm not seeing?
This is so that I can do the following steps to solve the access denied problem...
5. In the Policy pane, right-click Impersonate a client after authentication, and then click Properties.
6. Click Add User or Group.
7. Add the worker process account that is configured in the processModel element in the Machine.config file.
Please note that I have already added the IUSR with permissions to the directories I'm running the website from.
ok after some more digging I finally made it work. I didn't have to add any worker account in the process model block of the applicationhost.config
I just had to install HTTP Activation from the advanced service as described in one of the answers in
what to do when accessing http://192.168.1.213:51258/Default.aspx doesnt work
I then followed with
netsh http add urlacl url=http://192.168.1.213:51258/ user=everyone
But that didn't solve it so I followed the change of configuration in visual studio web server to use custom server to finally fix this, found in the link below
how to setup custom web server in visual studio

how to Execute .aspx file on server

Sir,
I have designed a website using Visual Studio using asp.net, it is successfully getting executed on localhost
I want to make the website live on my own server.
After uploading the project files on server and then checking on the link www.abc.com/project
it gives the following error:
Forbidden
You don't have permission to access /project/ on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at abc.com Port 80
Note: the host is linux based server, and the website project is not having a database
Edit:
You added to your question that the host is a Linux server running Apache. You cannot run an ASP.NET application on Linux/Apache.
Prev: I'm leaving the information below for other people who might search for this problem when running IIS.
Locate the folder's physical location on the hard drive and pull up the Security settings. Depending on what operating system you are using, make sure the following have read/execute privileges (write as well depending on the functions of the site):
IIS_IUSRS
IUSR_MACHNAME
NETWORK
NETWORK SERVICE
If you still have problems, open the Web.config (or machine.config) and add
<identity impersonate="true" />
in the System.Web node.

Cannot log on locally IIS [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
What causes this error, how can I fix it?
Detailed Error Information
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x8007052e
Config Error Can not log on locally to C:\inetpub\wwwroot as user administrator with virtual directory password
Config File Unavailable (Config Isolation)
Requested URL http://192.168.0.3:80/
Physical Path C:\inetpub\wwwroot
Logon Method Not yet determined
Logon User Not yet determined
Config Source
<application path="/" applicationPool="PS-Extranet">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" userName="administrator" password="[enc:AesProvider:PrISRz2ggJH4bV46ktObfCSh91Y/yF9pAoLmH7eCnj0=:enc]" />
</application>
I had the same issue, but reason was different.
In my web.config there was a URL rewrite module rule and I haven’t installed URL rewrite module also. After I install url rewrite module this problem solved.
Looks like the user account you're using for your app pool doesn't have rights to the web site directory, so it can't read config from there. Check the app pool and see what user it is configured to run as. Check the directory and see if that user has appropriate rights to it. While you're at it, check the event log and see if IIS logged any more detailed diagnostic information there.
On Windows 10 I had to install ASP.NET 3.5 and ASP.NET 4.6 under Internet Information Services (the other boxes automatically check themselves):
Finally I get the solution for my problem. The asp.net account not appear in the IIS manager because I didn't check its check Box in IIS to do this in windows 7 follow the steps
Open control panel
Click on” program” link (not uninstall programs)
Click” turn windows features on/off” link
locate” Internet Information services IIS” in the pop up window and expand its node
Expand the” World Wide Web Service” node
Expand “Application Development Features” node
check the check box of”ASP.NET”
Then click ok button
Now you will see the Asp.net account on the IIS manager and by default you see IIS account Now you should move you asp.net website from “my document” to another place the IIS have permission to access it (to any partition on your computer) Now browse your website from IIS manager and it should work.
We got this error after having to change our domain administrator password.
After monkeying with several settings, I eventually found that in the application in below path as it was set to specifically use the domain administrator account rather than pass-through authentication (who knows why).
IIS Manager -> Basic Settings -> Connect
you need to do one step:
run->cmd
run "c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i"
Thats it
Experienced this issue today and resolved it. Someone had set the "Path Credentials" for the "Default web site" in IIS to run as a specific user. This same user changed her password either due to the password expiring or just a routine change. Setting the "Default website" to connect as the "Application User" via the basic settings option resolved it for me
you probably change your NT password.
Open IIS -> Right click on your application -> manage application -> advanced Setting -> physical path credentials.
good luck
In my case, this error appears after changing folder's solution.
I solve the problem by goin to my project properties and recreate my virtual directory.
Right click on project > Properties > Web > Under Servers section click "Create Virtual Directory"
It will display a message saying that the virtual directory was created in another place and it will change it
For me, I needed to enable Http Activation under the .Net features in "Add/Remove Windows Features"
Got this working alright but not based on suggestions above. My case is that am getting the 500 error running iis7 on a windows 2008 server in a domain. Just added a new user in the domain and basically allow read/execute access to the virtual directory or folder. Ensure that the virtual folder>basic settings> Connect As > Path credentials is set to a user with read/xecute access. You can test settings and both authentication and authorization should work. Cheers!
Default web site need to manage as well:
1 .On Default web site -> basicSettings -> connect as, change it to the right user.
2.change the Identiy of the applicationPool that related to the defaultWebSite
g.luck
Right now i had this error and resolved it. Your url could match with created virtual directory.
You have to check virtual directories, in my example i found in applicationhost.config next row:
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/admin/roles" physicalPath="C:\..." />
</application>
I tried to open page with an url (http://localhost/admin/roles) of AdminController and Roles action and got this error.
For others out there, I got a similar error message due to trying to run a .Net 4 app in a .Net 2 app pool. Changing the .Net FX version for the app pool fixed it for me.
I was having a similar error installing php 5.3.3 with the Error Code 0x80070020 with a direction to a few lines in web.config in my www root directory (not the standard root directory).
The solution, while crude, worked perfectly. I simply deleted the web.config file and now everything works. I spent HOURS trying other solutions to no avail.
If anyone thinks this was stupid, please let me know. If anyone else has spent the same amount of time pulling out hair, try it and see (after backing up the file of course)
Regards FEQ
Was having the same error and fixing the credentials in the IIS app pool did not help. I finally resolved the error in IIS by selecting my website under Default Web Site, Advanced Settings->Physical Path Credentials->Specific User, and reentered the credentials for the app pool user, then restarted IIS and the error went away and my website came up successfully.
As I got the 500.19, I gave IIS_IUSRS full access rights for the mentioned web.config and for the folder of the project. This solved the issue.
You can give permissions by
right click on the folder / file
selecting the tab "security"
add the user IIS_IUSRS - don't forget the i in front of USRS and don't write an "e" as in USERS
If it's bigin when you try to acces to joomla administrator panel, Just a username and password problem !! You have just to update a jos_user in your joomla database.
Go to your joomla web site directory and open a configuration.php with bloc note or note pad to show what database name your joomla administrator site use.
You have to find a line who have:
public $user = 'joomlauser251'; //MySQL username
In my case joomlauser251 is my DB name.
Login to your mysql:
mysql -uyourusername -pyourpassword
Select database for your joomla:
use joomlauser251;
Change password for admin:
UPDATE jos_users SET password=MD5(‘NewPassword’) WHERE username=’admin’;
And retry to acces again.
That’s all !!!
Didn't seem to be a permission issue for me - tried giving the IIS_IUSRS account full control over everything in the web service, just to see if this was the cause. The fix turned out to be recreating the application hosting the web service (i.e. the actual '.svc') in IIS
In my case, I found a reference to an old domain account password in applicationHost.config under Virtual Directory defaults.
so easy
find the file "applicationHost.config" in Windows -> System32 ->inetsrv -> config
1. backup "applicationHost.config" to another filename
2. open file "applicationHost.config" clear data and save
3. open browser and call url internal website , finished.
If you are using a new, dedicated, user account... It is also worth checking that the password for that account has not expired, as that will also cause this 500.19 permissions issue.
For ASP.NET Core websites, this generic error will also occur if you don't have the HttpPlatformHandler module installed, see this answer for more details.
ASP.Net applications come pre-wired with a handlers section in the web.config. By default, this is set to readonly within feature delegation within IIS. Take a look in IIS Manager
1.Go to IIS Manager and click Server Name
2.Go to the section Management and click Feature Delegation.
3.Select the Handler Mappings which is supposed to set as readonly.
4.Change the value to read/write and now you can get resolved the issue
I have just one more thing to say about this. With the same HTTP Error code, you can still have several different errors, as one of them has been posted here at the original question's description.
For example: after I've edited the Web.Config file of an ASP.NET project, I had
Error Code 0x8007000d
"Only one <configSections> element allowed. It must be the first child element of the root <configuration> element "
As it says, you must NOT insert your own XML stuff before the <configSections> part of the Web.Config file. After I've inserted my snippet after the end tag of <configSections>, it worked just fine.
My website's correct path was not specified in IIS.
My solution is that,
just delete the corrupted folder.
Then re-create folder again.
It seem that if the corrupted folder had been created before IIS
setup. If you created folder again, it will work correctly.
I got this error after uninstalling Windows Server Update Services (WSUS) from the computer running IIS. Apparently uninstalling WSUS may break the IIS configuration on the server making other web application installed on the same server unavailable.
I found the solution for the problem here.
In my case, the value of the Key was incorrect in Web.config file:
<defaultDocument>
<files>
<add value="Portal.htm" />
</files>
</defaultDocument>
when I change the value to "Portal.html" it worked.
I got this error after upgrading from Visual Studio 2013 to 2015. After a bit of searching and trying various fixes I found the problem can be resolved by removing the following from web.config:
<staticContent>
<mimeMap fileExtension=".less" mimeType="text/css" />
</staticContent >
Apparently staticContent is deprecated now?
Source
Edit 1
This sort of prevented IIS from serving .json files when the program was deployed. If you do this you're supposed to re-add .json (application/json) to the mime types of your site in IIS. Here is some more info: http://www.iis.net/configreference/system.webserver/staticcontent/mimemap
Edit 2
I noticed that in my situation the above edit 1 solution only works temporarily. Once I redeploy the entry gets removed. So, I moved the mimeMap XML into Web.Release.config. Works fine now.

Do I need a web config file to run an asp.net hello world on IIS 7?

I have uploaded a simple hello world on my IIS server 7 (shared hosting). It doesn't work. Is it necessary to add a web config and what's the minimum in that case ?
Thanks.
Error says:
Server Application Unavailable
The web application you are attempting
to access on this web server is
currently unavailable. Please hit the
"Refresh" button in your web browser
to retry your request.
Here's the script, very basic :)
<%# Page Language="VB" %>
<html>
<head>
<title>ASP.NET Hello World</title>
</head>
<body bgcolor="#FFFFFF">
<p><%= "Hello World!" %></p>
</body>
</html>
A individual, site-specific web.config is not required to be present in order to get a basic "Hello World" site up and running in IIS7, however, it's rather unusual not to have one.
IIS7, unlike previous versions, effectively has the ASP.NET worker process component "built-in". This allows web.config files to specify configuration of not only your ASP.NET site itself, but also how the IIS server hosting your site should be configured (i.e. you can specify (for example) the default document type in an ASP.NET web.config file).
If you don't specify an individual web.config for your ASP.NET site, the IIS7 server will use the "default" web.config, which is usually located in your "windows" folder within the system-wide configuration of the .NET framework itself.
This article:
Working With Configuration Files in IIS 7
from the MSDN library states:
Configuration Files
Configuration exists in a physical
directory in either server-level
configuration files or in Web.config
files. Every configuration file maps
to a specific site, application, or
virtual directory.
Server-level configuration is stored
in the following configuration files:
Machine.config. This file is located in
%windir%\Microsoft.NET\Framework\framework_version\CONFIG.
Root Web.config for the .NET Framework. This file is located in
%windir%\Microsoft.NET\Framework\framework_version\CONFIG.
ApplicationHost.config. This file is located in
%windir%\system32\inetsrv\config.
Site, application, and virtual and
physical directory configuration can
be stored in one of the following
locations:
A server-level configuration file. When configuration for a site,
application, directory, or URL is
stored in a server-level configuration
file, you must use a location tag to
specify the site, application,
directory, or URL to which the
configuration applies.
A parent-level Web.config file. When configuration for an application,
directory, or URL is stored in a
parent-level configuration file, you
must use a location tag to specify the
child at which the configuration
applies.
The Web.config file for the site, the application, or the directory.
When you configure settings for an
application, directory, or URL, the
configuration is stored in the same
directory as the site, application, or
directory. You do not need to use
location tags.
Storing configuration settings in a
parent configuration file is helpful
when:
You want to store configuration settings in a configuration file that
is accessible by only certain users or
groups. For example, the
ApplicationHost.config file is
available only to the Administrator
account and to the members of the
Administrators group on a specific
computer, as well as to domain
administrators when a computer is part
of a domain.
You want to configure a feature at the URL-level (also known as
file-level).
Also, see the following article for further information:
The new Configuration System in IIS 7
EDIT:
Regarding the specific error message that you're getting, I've seen this before on an IIS7 server, and the problem turned out to be the Application Pool that the site was set to use wasn't "running". Going into the IIS7 admin gui and starting the Application Pool cured the problem.
I have also seen this error caused wen the relevant permissions have not been set on the folder containing your website code.
See here, here, and here for further information.
Of course, since you're testing a shared hosting environment, you probably don't have access to the web server itself, and it's difficult to know exactly what you do have access to, administration-wise, through your hosting provider, but they probably have some kind of interface to set permissions on folders/files, so I'd look there first.
Failing that, you may have to include a web.config file in your "test" site as that will allow you to set configurations within IIS7 that you may otherwise have no access to.
Failing that, you may need to speak to your web host's support team.
It should be enough to inherit from machine.config. What's the exception?
I am not sure about the shared Hosting environment. But If you try to create a web application ( try ASP.Net Empty web application template) and just use Response.write("Hello World !") . it will work without any web.config.
I tried my self and it work successfully.
Only problem is that It may ask you if you wanted to debug your application then it requires to add "compilation = true" attribute in web.config.

Resources