Click here to Skip to main content
14,450,167 members
Rate this:
Please Sign up or sign in to vote.
I have a very simple mvc4 application with Windows authentication enabled and deployed to IIS7. This application is then accessed via a Sharepoint Page view Web part.
The web application itself consists of a single controller, model and view with an Html helper Ajax form. The applcation itself works fine, without problems.

I used the standard internet template and deleted all the other views, models and controllers. I have not deleted any of the script files as I am not sure which ones are safe to do so.

I have configured windows authentication in the project's root web.config:
<authentication mode="Windows" />
  <deny users="?"/>
<identity impersonate="true" userName="domain\serviceaccount" password="pw" />

In IIS all authentication types are disabled except; Impersonation and Windows Authentication.

As you can see, I have removed the deny users = ? section because when it is included the problem occurs all the time.

The problem is with the authentication, when I run it locally in debug mode it works fine. If I deploy to IIS locally it works but I have to navigate there a few times before it does. Also other users are also able to access the site hosted on my machine but also need to navigate there a few times.
It also works in Sharepoint but I will need to navigate there a few times as well, but remote users don't seem to be able to access it at all.

When it does not work, it seems to be automatically redirecting to a non-existent login.aspx page. It should not need to do this because this site is only accessed from inside the domain and all users are already authenticated.

When I deploy to a remote server, it does not work at all. But that seems to be a completely seperate issue regarding a referenced library's dependencies and it fails to load the assembly. This is not the question/concern though. Well yet :)

Edit: By 'navigating there a few times', I mean. In the browser I enter in the URL (ie. http://host/webapp). If visiting for the first time it usually fails with a 404 error and the url in the browser has changed to 'http://host/webapp/login.aspx'. I then delete the 'login.aspx' part and hit enter. It might fail again, so I repeat the process. After two to three attempts it works. Within Sharepoint I can just click a link to go to the page. The first time I click the click, it probably won't work, click it again a few times and after two to three attempts it works.

Assistance is appreciated, and thanks in advance.
Let me know if you need more info.
Updated 3-Oct-12 21:57pm
Karthik. A 3-Oct-12 22:46pm
What do you mean by "you have to navigate few times" ? Check the credentials sent to the server. You can use IIS logs to see whats being sent as the credentials (just the user name though). And does the remote server have mvc (4) installed ? If not it will normally fail with not being able to load System.Web.Helpers.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I recreated the project using the intranet template as opposed to the internet one. Which is what I should have done from the start of course.

The reason I used the wrong one in the first place was that I followed a tutorial when I started and didn't even look at what other options were available.
This is not to say that I fixed the original problem. My understanding is that it should have worked the way I did it previously but I don't know what is being done in the background when the different projects are used and I don't have the time to spend investigating.

The other problem I was having with loading the third party assembly just went away.
So all is good now - except my project is another day behind. Oh well.

Thanks and Regards,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100