How to set up IIS 10 for MVC 5? - asp.net-mvc-5

The title is purposely generic as I have no clue to formulate my question in any different way.
I have made an MVC 5 project using .NET 4.7.
My goal is to use IIS 10 to point to a domain so I can use that as a testing ground.
I have already edited my host-file to point my localhost ip to the domain I have in mind.
After that I have followed every step mentioned in the video below meticulously.
However I keep ending up on the 403.14 error page.
I have adjusted security to no avail, checked the app-pool to use the correct .net version... I'm all out off ideas.
https://www.youtube.com/watch?v=IwbKquNBNgQ
I hope someone here has some idea of things I have not thought of myself, so feel free to ask anything you think might make the change I need to make this work. I will edit this message (and title) as much as needed to keep up to date as possible.
EDIT: I have followed the full guide that I have marked as an answer. I had 3 differences.
Difference 1 was in Windows Features. I think I just plain didn't correctly mark all the needed features..
Difference 2 was in Security. I did not have IIS_IUSRS added, only IUSR
Difference 3 is one I have purposely keep a difference and that is Directory Browsing. Without this being enabled, it works for me.
I hope that if anyone ends up on this page in the future, the answer provided below will be as helpful as it has been to me.

make sure you enabled below iis features:
please follow the below steps to publish your MVC project in iis.
1)open the visual studio. Select your site and right-click on that-> Click publish.
2)in pick up publish target Select folder option and create choose destination where you want to publish the site. (make a new folder and publish a site in that folder) and then select publish.
3)open IIS manager.
4)expand the server name and right-click on sites and select add a new site.
5)enter the site name, physical path, and site binding details.
ip address: select your machine ip address.
port: 80
domain name: your domain name
6)make sure you enabled directory browsing in iis.
7) The application pool is running under application pool identity, a version is correct and using the integrated pipeline.
8)anonymous authentication is enabled.
9)iis_iusrs and iusr have full permission to access the site folder.
host file enry:
bind your machine IP dress with a hostname of the site.
after doing all the changes refresh the site in iis and browse.

Related

Adding website to IIS

So, I did something and my localhost website gave me a 500 error. Couldn't figure it out so I figured I'll delete the website in IIS and then re-add it. Apparently that was a mistake. I can't see the added website locally anymore. I seem to recall having to add a permission or something to be able to view it in localhost but for the life of me I don't remember what setting that was and I can't find it online. Any ideas? My other local website still displays fine ... Using Windows 8 IIS 8.5
I'm simply going to Add Website > putting in the site name and changing the port number. I've left the IP address alone to All Unassigned (I just want to view in as localhost:24)
Adding website in IIS:
1. Right Click the Sites Folder image.
2. Add website.
3. Enter Site name.
4. On physical path textbo, Locate where do you want to store your website.
5.Assign a port.
then done.
After creating.
1. Select website created.
2. Open Directory Browsing.
3. On the right side click disable.
Make sure in application pool that your website has same framework set up.

IIS 8.5 is not serving JS, CSS, and Image files (static content)

The problem
We're running IIS on Windows 8.1 with Update. We're at the Orchard CMS first time setup screen, and IIS is giving 401s for all static content. We have read the following to no avail:
IIS 7.5 no images css js showing
IIS 7.5 no images css js showing
The official Orchard deployment documentation
Based on those, this is what I have tried that doesn't work.
Turn on the IIS feature to Serve Static Content.
Give IIS_IUSRS permission to Read, write & execute.
Give the site's application pool permission to Read, write & execute.
What does work though is the nuclear option: to give Everyone the Read permission (unless we want to proceed with the Orchard setup; then we need to give Everyone even more permissions.) That leads me to believe that I must give permission to some principle with less scope than Everyone but more scope than both IIS_IUSRS and the application pool combined.
Who/what is that principle?
Pictures to show the problem
We receive a 401 on ..\Themes\SafeMode\Styles\site.css
The task manager confirms that the site is running as the orchard user.
The security properties of the ..\Themes\SafeMode\Styles\ directory gives Read permission to orchard.
Why does it only work when we give Read permission to Everyone?
I had a similar problem. Under authentication, I right clicked "Anonymous Authentication" and clicked "Edit". That shows a dialog giving you the ability to set the identity of the anonymous user. I set it to "Application pool identity" and that fixed the problem for me.
.
This may not be the most secure configuration though, but I'm on a dev server so I don't care.
Try turn on the Static Content and Directory Browsing features under Internet Information Services->World Wide Web Services->Common HTTP Features node.
In my case I had to set Read permission for IUSR user for the web site folder.
So, what I had to do to fix this problem was the following:
(and please understand, that this is not ASP or PHP script related, the server wouldn't even show basic simple .html files, yet would serve out PHP results all day long!)
Two fold…
Had to set the application pool for each site, under advanced settings, to use LocalSystem for it’s process
Under site, advanced settings, security, add the IUSR account to have read & list contents access, for the site… :-)
See any problems with doing that?
'cuz it's working....
Updating windows feature for WWW services/Common Http Features/static content by selecting Static Content checkbox fixed my IIS not service static content issue.
Open IIS -> go to advanced settings of selected website and open Physical Path Credentials -> Select specific user and enter your local user credentials. Open below screenshot for further visualising the things:
IIS Settings

Installed IIS but get blank page and it doesn't show up in Windows services list

I am trying to install IIS on my Windows 8.1 laptop and followed the directions at Microsoft for installing IIS. But when I type localhost, instead of getting the IIS start page, I get a blank page.
When I do Windows + R and type services.msc, the resulting list of services is long but does not include Internet Information Services.
When I look at the Windows filesystem, I do find the inetpub folder with four subfolders, including wwwroot. In the wwwroot folder is the iisstart.htm file that is supposed to display when I type localhost into my browser.
I have read that one possible problem is that both Skype and IIS want to use Port 80 and there is a conflict. So I decided to try to change the default port for IIS, but I found that I don't appear to have the IIS Manager on my system. When I go to Administrative Tools, Internet Information Services Manager is not on the list of administrative tools.
I added both the HTTP Redirection module as well as the IIS Management Service on top of the initial basic installation that Microsoft described. Still no luck getting IIS working or IIS Manager to appear.
I have tried to research this problem of getting IIS to work on Windows 8.1 with no success and am at a loss. Suggestions welcome!
In Control Panel --> Programs --> Programs And Features --> Turn Windows features on or off -> Internet Information Services -> World Wide Web Services -> Common HTTP Features -> Static Content.
Also make sure .NET Extensibility 3.5 and .NET Extensibility 4.5 are checked.
Major fail by Microsoft. Why the hell would they turn off the most basic features by default. Go to Turn Windows features on or off (just search "features"). Look in IIS, WWW, Common HTTP Features. See attached image.screenshot
I have solved a couple of my problems.
I installed several more IIS modules: Static Content, IIS Management Console, and HTTP Errors.
I am now am able to find the IIS Manager in the Administrative Tools list and can use the IIS Manager.
Also, when I pressed Windows key + R and typed in services.msc, I still don't see Internet Information Services in the list. However, I do see "World Wide Web Publishing Service" in the list and it is shown as running. A page at Microsoft's Technet site indicates that it is related to IIS.
The HTTP Errors module gave me an error page rather than a blank page when I typed in localhost and also when I typed localhost/filename. This proved a HUGE help, because the error page identified the problem as a permissions issue. I thought I had dealt with the permissions issues, but this error page made it apparent that I had not.
When I typed in localhost, I got the permissions error. When I typed in localhost/iisstart.htm, I got the proper display of the file. When I created a simple .htm file, statictest.htm, and placed it in the wwwroot folder along with iisstart.htm, and typed localhost/statictest.htm, I got the permissions error.
So since one of the files was working and one wasn't, I decided to compare their permissions. (You do this using the File Explorer. Right click on the file, click on Properties, click on Security Tab. To make changes, click on Edit.) I saw that the successful one had a user listed that the unsuccessful one did not. So I added a user for the statictest.htm file to the permissions list with full control. That solved the issue for that file and it displayed normally.
I now am back to getting a blank page when I type in localhost. It must not be a permissions issue, because otherwise I'd get the permissions error page. I'm not sure what the cause of the blank page is. But as long as I can get files to display when I give their name, I am happy enough.
I am happy to report that my PHP installation is also working, at least as judged by the fact that the phpinfo() function displays properly.
So to sum up: if you are having problems getting IIS to work on Windows 8.1, try adding more IIS modules and make sure your permissions are in order. I think the most important ones to add are Static Content and HTTP Errors. Also, of course, CGI if you are going to use PHP.
I know this is an older post, but in case anyone, like me, already had "static content" enabled, there was one other thing that needed to be done to resolve this issue.
Under "Programs and Features" -> "Turn Windows features on or off"
Expand "Internet Information Services" -> "World Wide Web Services" -> "Application Development Features"
Make sure that "ASP.NET 4.5" (and if needed/installed 3.5) are selected. This should automatically check ".Net Extensibility" for the selected version, and it should also enable ISAPI filters and Extensions.
By default (for me at least) these options were not turned on when I enabled IIS. I was getting a 500 error in IE if I had "Show Friendly Error Messages" turned on in IE, but if I turned that option off, I would get a completely blank page.
For me, the reason was that I had two different HTTP handlers in the config with the same name. I didn't get any errors, just blank response.
I'm guessing that some other parts of the configuration may result in a similar behavior. Try commenting out some parts of Web.config file in case you cannot figure the problem out.
Same issue.
Win 10 upgraded from 7. Default documents server blank and without error.
Static Content and Default Document features already enabled.
I resolved by disabling both features, rebooted and tried(received error 404), enabled both features, rebooted, pages served properly.
For me, I was using Windows Server 2008 on an Azure machine, it was missing some packages which can be installed using "Web Platform Installer", and then search for "recommended server configuration for web hosting providers"
I encountered the blank page problem as well on IIS 8.5 on Windows Server 2012 R2.
I had StaticContent installed as Windows feature.
What finally fixed it for me was changing the Path Type of the StaticFile Handler under [IIS Manager -> Server on left pane -> Handler Mappings -> StaticFile] from "Unspecified" to "File or Folder".
You can also change this on a per web site basis instead of the entire server (but I don't really see a reason why to do so, as it breaks pretty much any page). Make sure, however, that the site does not have an overriding setting for the StaticFile handler, as the site scoped one is preferred over the global one.

SharePoint development nightmares

I thought I'd give SharePoint development a go, to broaden my understanding of Microsoft technologies and ran into a situation I refuse to understand.
I have a new web application created: http://localhost:11523 and set up the site collection as required. I can browse to the web site fine, without any issues, but now I want to start developing against this, using the object model.
Right, so after I struggled with SPSite site = new SPSite("http://localhost:11523"); I figured that I'm not running VS2008 in elevated permissions, so restarting VS I finally got one step further.
Whenever I step into my code, I get:
The Web application at
http://localhost:11523/ could not be
found.
I've Googled this without luck. The application is most definitely there, I can browse it, add web parts and go mad. I just can't seem to connect to it via Visual Studio.
Any ideas would be great.
EDIT
I thought I'd isolate my method, called "GetListFromSharePoint(string name)" into a test method (nUnit Framework) and to my surprise returned 9 entries from the list, as expected. When I dumped the method back into my web application (not SharePoint, trying to test the Composite Control through a normal Web site), and run into the mentioned problem.
This is in SharePoint 2007, and I'm developing on the same machine onto which SharePoint 2007 is installed.
This approach used to work, for some reason, I just can't get it to recognize SharePoint. The test stubs work find, just not the web application.
Edit 2
So there where a couple of things I "missed", which kind of solved the problem by itself.
Firstly, I was developing on a x64 Windows 2008 box, thus SharePoint 2007 was running in x64 mode. Cassini, turns out, is 32bit regardless of the platform you run it on, which caused some compiler bugs (I did not have IA64 compilers installed). After installing this, I figured out that the default web site (localhost:80) had been disabled by SharePoint.
Renabling the default web site, allowed me to create my web application as a virtual directory against it, which allowed my debugger compiler to run in x64.
My next challenge was access permissions. Because any new virtual directory on port 80 is assigned to the default application pool, is it assumed that the user does not have the right permissions, so I had to change my web application to run under my SharePoint web application's application pool.
The last thing I had to do was run my SharePoint code with elevated permissions.
Working like a charm :D
Note! Enable debug on your SharePoint web application....
Thanks,
Eric
(You have not specified version - assuming SharePoint 2010).
You need to decide what object model you want to use:
client (to be able to access the server from any other machine)
server (the one that you are trying now, can only be run locally).
Most likley reasons your code not work:
using "localhost" instead of ""computer name" in the Url. (I believe it is the reason.)
you are running your code not on the same machine as the SharePoint
you are running code under non-admin account
Check out how sites collections are configured in "Central Administration" site - urls associated with each site collection are listed there - make sure you are using correct one.
You can also try enumerating all site collections in SPWebApplication (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.sites.aspx) to start expiriments.
I dont think the SPSite connect through the IIS, and if SharePoint isn't set up to respond to localhost (done in the Central Administration) you wont be able to connect to that url. IIS works a bit different here since it relays the signals to "localhost" to the "web application instance".
Start by checking in your SharePoint Central Administration. Go to "Configure alternate access mappings" in the "System Settings" section. Here you have your SharePoint instances, there are three properties which you can see directly in the list; 'Internal URL', 'Zone' and 'Public URL for Zone'.
If the Internal URL isn't set to Localhost you wont be able to use that connection you suggested. It bay be improper to change this to another url as well, so simply try to set your SPSite site = new SPSite("http://yourinternalurl:11523"); to whatever's in that box! :)
Cheers

Moving sharepoint installation to a different port / URL

We've installed Windows Search Server Express on one of our servers, which apparently runs on top of sharepoint.
Sharepoint was installed on port 80, where our "normal" intranet runs. When I disable the intranet and run the sharepoint site, everything works as intended. The intranet is linked in many places it would be a pain to move it, so I'm trying to move sharepoint to another "place" (hoping this is less of a pain), either a different port or as a virtual directory under the main site.
First, when I make any of these changes, it fails to get access to the intranet root. Not sure what it is looking for there, but ok, I give "Network service" (the acocunt the "Sharepoint 80" application pool is running under) access to the intranet root. This gets me one step further, I am stumped:
When I move the Sharepoint website to another port, it complains that it can't find default.aspx (there is none, but also it doesn't need it when running on port 80)
When I move it to a sub folder of the existing site, and try to open the global.asax in the browser, ti tells me that this extension is prohibited, even though the "Application configuration" is - as far as I understand - identical to that of the Sharepoint site, and allows GET, HEAD, POST, DEBUG for .asax.
Any suggestions?
Sharepoint sites should be able to run on any port- if you go into Sharepoint Central Admin and create or delete web applications without a problem.
Is it your intention to run heterogenously with Sharepoint and your regular site both on Port 80? I know that you can create a web application on 80 and then not have a root site collection ( Sharepoint applications consist of a Web Application that runs on a certain port and any number of Site Collections within that, each of which has it's own directory path and can contain lists, libraries, other Site Collections and so on ) just creating one on a different path, but I don't know for sure how that would work alongside an existing web site on the same port- it may not play nice. Again, you can create and delete site collections from the Sharepoint Central Admin page, which is linked from your Administrative Tools list on your server.I would try this first, as if it works it's an easy solution.
Is Windows Search Server Express related to Sharepoint's own search facilities? If it is you may find that it expects to run using some of the Shared Service Provider facilities, which even Sharepoint doesn't expect to be running on the same port as the sites it's providing services for.
An even better way would be to create another alias (cname) in your DNS for your server, just set a different host header for each web site.
for example, in DNS your machine might be named 'intranet'. Create an alias for that machine named 'sharepoint'
In IIS, create a new website for sharepoint, and set the host header for that site to 'sharepoint.domain.com', where domain.com is your domain.
Do the same for the intranet website, but set the host header to 'intranet.domain.com'
That way, your users don't have to use another port in the URL.
Thank you! I found the option in the sharepoint administration website.
I add this response to detail the steps I have taken - maybe they are useful for someone else.
In the sharepoint administration website (running flawlessly on another port), I chose "create or extend web applications", then "extend existing web application".
There, from the the drop down "Web application", "change web application" opens a popup with the web applications available. Search server was installed as "Sharepoint 80", so I selected that.
Then I selected "Create new IIS website", with a new name and a new port. All the other options looked fine to me as default.
Clicking OK, this creates a new web site in IIS, which was configured correctly. it doesn't work via the IP address of the server (http://192.x.x.x:8080), only using the server name - but that's ok with me :)
I still had to make some adjustments with the access rights, but the full crawl is running and I can find a few documents already. Yay!
This is much easier when you first backup your site and then create a new site from the central admin with a new port number and then restore the backup to it(overwrite)

Resources