Not able to access my MVC 5 web application after adding MS Identity - asp.net-mvc

I created my app using a template. After that i managed to connect it with an existing database. Then i tried to add Identity so that i will be able to authorise and authenticate users of the application. I tried to do that following the instructions of "shyamal parikh" in this post Adding ASP.NET MVC5 Identity Authentication to an existing project
My problem is that now i get a 401 error unless i got to solution explorer (in VS) and disable the windows authentication. But when i do that all the users have unrestricted access to the whole application.
I assume that the problem has to do with that solution that i performed but i cant comment directly there.
Can anyone give me a hint as to what i might be doing wrong?

Do you have windows authentication installed on your computer? Maybe adding that might help. Here are the instructions-
https://www.iis.net/configreference/system.webserver/security/authentication/windowsauthentication/providers/add
Also look at your event viewer, you might have some hints there.

Related

New ASP.Net project but asking to sign in

I created a new ASP.net core project using VS2019. I did not modify anything from the automatically created weatherforecast controller. My problem is, everytime I just try to debug, the browser pops up asking me to sign in. Is there a default user and password created? How to solve this?
It is probably you are using Windows Authentication while create your Asp.NET project, try uncheck Authentication it will allow getting into the landing page of your application
Make sure that during the creation of the project you didn't add authentication. There's an option to add authentication by default.

ADFS 2.0 with ASP.NET MVC 4

I wanted to implement a small Proof of Concept for ADFS integration with MVC application. For this I created a virtual machine for Windows 2008 R2 and configured ADDS, ADCS and added my updated my server domain to one created one using ADDS.
After this I created certificate using ADCS.
Now, installed ADFS 2.0 using Microsoft download of ADFSSetup.exe RTW.
With help of some I configured ADFS & added relying party trust from my MVC application SSL URI.
After this I tried to run the application however started facing 403.14 error page.
Following observations as outcome from entire configuration:
I tried to access "<>/federationmetadata/2007-06/federationmetadata.xml" and I
got a proper XML which is as per expected.
I saw couple of entries from server computer - IIS website as like "http://<>/adfs/services/trust" OR "https://<>/adfs/ls/" however couldn't get any response from server. even I tried to access same from server using localhost instead of server names, then also no luck.
Then to cross-verify I checked IIS's default website where I found adfs/ls however it was a like a website. Not sure correct or not. I couldn't find anything 'services/trust' under ADFS IIS application.
After that I installed ADFS from Server manager and saw one more virtual directory 'fs',added under adfs application. when I tried to access 'fs' using https I am able to access it easily and can see SOAP service and page displayed with available web method.
I tried to find more on 'adfs/ls' and 'adfs/services/trust' however couldn't get much more information.
Please, if anyone came across this issue. Do let me know.
This is not an issue, this is how ADFS works. Next step you have to configure claims providers and relying parties from ADFS management console (from Admin tools). Relying party could be a sample claims aware MVC application. It should work
The only URL's that ADFS "answers" to are the federation metadata endpoint and the IDPInitiated one.
adfs/ls expects either WS-Federation or SAML parameters after it. On its own it will throw an error.
Then follow How To: Build Claims-Aware ASP.NET MVC Web Application Using WIF.
Why are you using Windows 2008 R2? (ADFS 2.0)? You should rather use Windows 2012 R2 (ADFS 3.0).

How to publish ASP.NET MVC on IIS server

I am struggling with trying to publish a site.
I have made a basic web site with ASP.NET MVC and I now want to host it on a pc.
I have opened ISI manager and added a new site. I set the default directly to the directly where the files for the site are stored but when i navigate to the pc I don't get my site. I get an IIS server error in application error.
What steps do i need to do to get the a basic site to run on the server.
First, you need to have installed iis, this is done you have to register the asp.net framework, for this you need to run a command line.
Go to cmd and type:
aspnet_regiis -i
Done so please enter
http:// localhost/AplicationName
If you get an error, then you should really post that error with your question. However, since the most common problem in the scenario you describe is permissions, I'm going to assume that that is your problem.
Unless you're going to put your code in a directory owned by IIS (such as "inetpub"), then you need to give the IIS user or group rights to the directory your code is in. You can do this by right-clicking the directory in Windows Explorer, and choosing "Properties". Then click the "Security" tab. Use the "Edit..." button to add the IIS user or group. It should be named something along the lines of "IIS_*". You'll need to grant full control, so just like any other publicly available directory (including "inetpub"), you should ensure that there's nothing secure or compromising in that directory.

ASP.NET MVC Windows Azure organization authentication

I'm trying to configure the organization authentication in an ASP.NET MVC project in Visual Studio 2013 RC.
After filling the data in the create project dialog, like Microsoft instructed in their tutorials, I'm getting an error which says that the configure failed.
I've tried to do so as well in Visual Studio 2012 using the identity addon.
Maybe it's related to Windows Azure AD?
Here is the error that I'm getting:
Hopes that someone knows how to fix that issue. Thanks for any help and suggestion!
This question is old, but today I found a workaround that I'd like to share.
It seems like we can't use Microsoft Account when we're using WAAD.
So:
Create a WAAD.
Add an administrator
Choose local directory account, not Microsoft Account.
Grant this account Global Administrator permissions.
Open Visual Studio and create a new web based project.
Choose in authentication the "Organization Accounts".
Specify your WAAD URL (e.g. "foo#onmicrosoft.com").
When you're required to insert your user and password, use the local account username and password. for example ("oz#foo.onmicrosoft.com").
This will allow you to pass the error.
Edit:
Microsoft published a post that referred to this problem and show the solution (the one I described above). http://www.cloudidentity.com/blog/2013/12/11/setting-up-an-asp-net-project-with-organizational-authentication-requires-an-organizational-account/
I would check for two things:
The account used to login to Windows Azure while has Global Admin role in AAD
App ID URI specified in the project creation dialog is valid. Valid App ID URI for domain mydomain.onmicrosoft.com has format https://mydomain.onmicrosoft.com/uniqueUri. Note that you can leave this field blank and the tool will automatically pick the correct App ID URI for you.
If these two things don't help, I would encourage you to run DebugView (http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx) in the background while trying to create a similar project and you can see the actual error message in the trace in DebugView.
In follow up to OzB:
Once you've setup the user in AAD as per OzB's account,
note that you must also then go to "Settings" in Azure and add that account as an administrator of the Azure subscription, otherwise you can't upload the website itself.

Reading pst (Outlook) files from IIS ASP.NET application

I have to create sort of a .PST file based Web Mail.
I need to read all MailItems, Folders, Contacts and everything i can from PST files given by the user.
I am currently using DCOM interop to create a Application and use Session to add my file's stores.
My problem is that i can't even instantiate the Outlook.Application, the code simply doesn't run.
If i change to Visual Studio Development Web Server everything works as perfectly as expected, but if i change to local IIS Web Server.. nothing happens =/
What i did so far:
Set username and pass to impersonate on web.config
Set username and pass to inpersonate on my WebSite from iis -> Authentication -> ASP.NET impersonation
Added permissions to Everyone, Network Service, IIS_IUSRS, my user account in temp asp files, web site file and pst files i'm trying to read
Unfortunately I've already implemented all I need using TDD, so it would not be a good idea to change the way i'm doing this, like moving to NMapi or something.
Thanks in advance
EDIT:
As i've mentioned before, i I cannot use another library (and that one seems to work, but it's pretty expensive).
I only need this to run on a local server. It is a Web application, but for localhost ONLY.
It is not a good idea to use Outlook on the server side, as is described in detail here: http://support.microsoft.com/kb/257757
Microsoft does not currently recommend, and does not support,
Automation of Microsoft Office applications from any unattended,
non-interactive client application or component (including ASP,
ASP.NET, DCOM, and NT Services), because Office may exhibit unstable
behavior and/or deadlock when Office is run in this environment.
Maybe have a look at http://www.independentsoft.de/pst/

Resources