How to deploy an MVC application on IIS 7? - c#

I have a MVC application and I can't get it working on IIS 7. Debugging in VS2010 works fine, but when I publish the website to my local IIS7, I see nothing but blank pages.
Here is what I have done:
On the project, right click and click Publish. In the Publish Web window I set these settings:
Publish method: Web deploy
Service URL: localhost
Site/application: Default Web Sit\Africa
both, Mark as IIS application on destination and Leave extra files on destination (do not delete are checked.
In IIS, my application runs under a application pool with supports .net 4.0 and managed pipeline is set to integrated.
I don't get any error while publishing, but when I navigate to my site I only see blank pages. Nothing happens.
What goes wrong?
EDIT:
When I navigate to http://localhost/Africa/ I see a blank page. When I navigate to http://localhost/Africa/Views/Home/ I get a 500 error.
How can I solve this?

I ran in to the same exact problem, it took quite a bit of digging to solve.
I finally found the solution to it on this page: Getting an ASP.MVC2/VS2010 application to work in IIS 7.5
Yeah, I know that this is an old thread but for the sake of saving someone else's time I'm adding this. Also make sure you have HTTP Errors, HTTP Redirection, and Static Content enabled in IIS.

In your application pool advanced settings, make sure you have Enable 32-bit applications set to true.
Some other things to try:
Change the application pool to classic.
Make sure you have the correct version of MVC installed on your server.
If you are getting 500 errors, you can turn on Failed Request Tracing and check the logs. If you are getting 500 errors and no logs are being created, you need to check your web.config.

Blank page normally doesn't necessary mean it's not working, if you default page doesn't have anything, it will be blank.
If you run into some error, you normally will see an error page.

Related

Want to redirect to external link but it keep stays at current domain

Currently I have an web application with web page (Redirect.aspx) with the following codes in its PageLoad function
Response.Redirect("https://redirectURL.com/folder1/folder2");
In my local debug, I'm able to reach the https://redirectURL.com/folder1/folder2 when i access the Redirect.aspx
However, when I hosted the web application (as Sample.com) in AWS EC2 server, when i access the https://Sample.com/Redirect.aspx it go redirected to https://Sample.come/folder1/folder2 instead of https://redirectURL.com/folder1/folder2.
Not sure whats triggering the change of website hence hope to get some helps.
Have found the reason. It wasn't due to code, it was because of IIS setting.
In ARR - Application Request Module, there is a "Reverse rewrite host in response headers" feature and somehow it was turned on hence causing the issue. Turning off this solve my issue.

asp.net MVC, IIS - HTTP 404.0, 403.14

This is my first project in asp.net MVC. Build works in Visual Studio. When I publish website to server I get this two errors:
HTTP 403.14 – Forbidden
I get this one if I visit server based on ip. It says I can probably fix it by setting default webpage. I know where to do it in IIS, but I dont know what to put there. I have only one controller Home, which has Product view. So I tried to set Home/Product, but nothing happend.
HTTP 404.0 – Not Found
This is happens when I try to access to controller, x.x.x.x/Home/Product for example.
Project runs on Windows Server 2012 + IIS. In IIS I use Default Web Site. I added permisson to users from outside by this command IIS APPPOOL\DefaultAppPool.
In Visual Studio I make build through Build > Build web to local drive and move all files to server.
Two things,
Check the app pool identity has permissions to the root folder of
the site.
Check that there is a default page configured in the root folder in
the site and that the default page is listed in the default
documents list for the site.
403 Forbidden The request was valid, but the server is refusing
action. The user might not have the necessary permissions for a
resource.
404 Not Found The requested resource could not be found but may be
available in the future. Subsequent requests by the client are
permissible.
Options:
Is Directory Browsing turns to Enabled?
Is Folder Project Directory User has Permitted?
Check application pool framework(IIS) VS Project Framework.
Always check in application pool > right click created website > advance settings > General tab (32bit or 64bit)
Fix it by this advice: stackoverflow.com/a/9239936/3246527. Thank you all.
I probably followed some bad tutorial which missed this part.

Why is my Azure website no longer visible?

I have created a new website and published it (via Visual Studio) to Azure.
Initially, everything worked fine.
But, after republishing the website a few times, the website stopped responding - i.e. it shows a "Server not found" error in Firefox or "This page can't be displayed" in IE).
Now, any new website I publish shows the same error. (Here's a basic test site I published, so you can see the message: http://www.test-website.azurewebsites.net)
The previously published websites are still working; it is just new websites that are failing.
Does anyone know why this would be happening?
Additional Info:
The website was created using Visual Studio 2012 C# ASP MVC .NET 4.5
The websites are using Microsoft's 'Free' pricing tier.
There are a total of 3 websites on the Azure account.
Claies brought this up in a comment, and I'll take it a step further. Your link should not start with www. when you're visiting a .azurewebsites.net domain.
If you're just typing this, then that's the issue.
On the other hand, given that you're asking this, I'm wondering whether maybe your configuration file is a bit messed up in VS. When you run the publish wizard, try going back a couple pages to the page with the textboxes, and double-check that none of those refer to the www. version. If they do, simply drop that.
That settings shouldn't affect the publish itself, but it will determine which URL to go to when publishing completes, so you'll definitely want to get that fixed if it is wrong, or else this will just keep happening.

Code Build logs me out of application (IIS)

I have a peculiar problem that just started happening out of the blue.
I will build my application using an IDE, navigate to it in the web browser, and log in.
Log in uses FormsAuthentication to set a cookie.
I then found a bug so I fixed it and rebuild my application.
When i refresh the page I navigated to, it had logged me out of the application and ask to log back in again. (clears my cache or something . . . not sure, HELP!!)
Why is this happening, it never happened before and all of a sudden it started happening.
The application is hosted though IIS 7.
So solved my problem by setting Session Sate Mode Settings and using the State Server option. Just default settings did it for me.

RedirectPermanent causes odd results in an ASP.NET MVC 3 application

This is just strange. There could be other issues, but here's the deal. I'm making an application that simply gathers information and redirects to a URL with the info passed as parameters on the URL. I'm using the ASP.NET MVC 3 (.NET 4.0) framework and I've never had to redirect to a URL outside the application before.
My initial attempt, I did:
return RedirectPermanent("http://www.google.com?" + qrystring);
This redirected to google, but I didn't see the parameters. I work at it a bit and change the URL to one inside the application but I'll still be using the full URL and not the routing because I want to ensure the values get there. Now, when I debug the application locally and mouse over my breakpoints it says:
"The breakpoint will not currently be hit. No symbols have been loaded for this document."
Also, no matter what I change the URL to in my call to "RedirectPermanent", it always loads the Google page.
I've cleared out the Temporary Internet file history & ensured the ASPNET user has access to the folder. I've also closed & reopened the solution. I've also tried changing "RedirectPermanent" to "Redirect", but that didn't fix it. Breakpoints worked fine in this application before hitting that RedirectPermanent statement the first time.
FYI: I'm running Windows XP and am using IIS Express (ASP.NET Development Server). I'm also running the application locally in debug mode as opposed to on a server machine.
Thoughts?
This was a rather simple thing in the end.
Chrome cached the RedirectPermanent url. Debug symbols are loaded until later in the application when other initialization is done. Visual Studio loaded my application and chrome seeing the url being used performed the redirect.
I cleared out my cache in chrome and, presto, it all works fine again.

Categories