Here is my scenario: I have a web application developped on Razor pages and it's published on a server with IIS connected to the company's network. I use windows identification for the user to log into the application. Each time an user makes a change or uses the application I save windows user into a SQL database. The problem is that sometimes the user is not the current user using the application. It's not frequent that this happens but I'm wondering if an user leaves the app open and another user logs in then the new user is saved? I tried to replicate the error on my local machine but I can't get to the same problem. I use User.Identity.Nameand save the value inside a static variable. Do you know what can cause this problem?
Related
I have a C# MVC application, I publish it to an external hosting company, if I have say 10 users logged into the application what happens to their sessions?
I've noticed what will happen with me is I go to log into the application after a publish, it appears to log me in, however I use a client-side binding language called Knockout and so it then shows me the user interface, however it hasn't actually loaded the data back from the server. It looks like I'm logged in but if I hit F5 to refresh then I'm logged out, it’s like the session is cached or something but not properly.
I'm thinking of implementing some sort of JavaScript timer to ensure the application has access and running it every few seconds, if it cannot access the server then redirect to the login page.
I am new to ASP.NET MVC and creating a little application in my spare time at work.
This application has windows authentication and connects to one of our remote test databases, and the application does some simple select/update/insert queries with one of the tables on this database.
For one part of my application, when a user clicks 'process', I save that user's username in my model by doing:
job.User = System.Web.HttpContext.Current.Request.LogonUserIdentity.Name;
And then write that to the database.
Everything run's fine when I run it locally through visual studio, it recognises my domain name/username and saves that to the database.
Once publishing to IIS, I ask one of my team members to connect to my computername/site and when they try to click that same 'Process', they get
"Login failed for user 'OURDOMAINNAME/MYCOMPUTERNAME$'. "
My application is using DefaultAppPool with Identity set as 'ApplicationPoolIdentity'.
My whole team has permissions to access this database and if only my application picked up their correct domain group/username then it would OK but the application is trying to connect as MY computer and not my actual windows logon.
Can anybody please advise?
Since you are using ApplicationPoolIdentity, did you allow that user in your MSSQL database?
User: IIS APPPool\DefaultAppPool
I have a Windows Service that is responsible for deploying desktop applications. It detects windows logons, and then should install applications into local appdata, and start menu icons in the correct place.
What is the correct way to find a given user's local app data folder? I have a session id, but no win32 user token.
OK, I solved it.
I was able to retrieve the user token given the session id by calling WTSQueryUserToken.
I was then able to present this token to SHGetKnownFolderPath, which returned the correct path for local app data.
I've been working on an asp.net 4.0 website and seem to be having an issue with deleting from the database stored in the app_data folder.
I created a domain group in the actice directory and used the web.config file to restrict access to certain pages that allow modifcation of the database. Everything worked fine on my test machine and the production server, but the issue is that on the server, even though it recognizes the user when you access the page, when you try to delete an item it denies access and does not allow you to delete the item.
The users had read/write permissions to the folder, but it still denied access. I did some testing and allowed everyone read/write acces, and it allowed me to delete, but I don't like having that option set up.
Does anyone know what causes this issue and what the proper fix would be? I'm assuming I have to let the website know which user is running the application before it tries to delete so they can write to the database, but I thought it would do that automatically since I used Windows authentication.
If anyone has any information I would greatly appreciate it.
The user account that is running the application pool for your website is the only user account that needs MODIFY permissions to that database file.
I have created a sample ASP.NET website and hosted it in IIS 6.0 . It is working fine , if the identity of the defalut app pool is "local system". But when i changed the identity with some other configurable user id then it is showing as "Service Unavailable".
The following message is found in the event viewver.
"The identity of application pool 'DefaultAppPool' is invalid, so the World Wide Web Publishing Service can not create a worker process to serve the application pool. Therefore, the application pool has been disabled."
Either the credentials provided for the user is not valid, or the user does not have the needed permissions.
I believe there is a security group on the machine called IIS_WPG that is created when Asp.net is installed, add the user to this group, it should give them the needed permissions.
Message is self-explanatory. The selected user id isn't valid - probably due to insufficient privaledges to run the service.
The user identity you use needs to have fairly significant rights to operate. At a minimum the user needs to have read/execute permission on the root directory of the folder. This user should also have read/write/execute permission on the Temporary Asp.Net Files folder located within the %SystemRoot%/Microsoft.Net/Framework/ folder.
FYI,
In a development environment you can use the default app pool to create your web applications.
In production environment you want to use lusrmgr.msc (Server 2008/R2/7 Ultimate and Pro) to create new users (and their credentials) on the machine and assign the users to the right group (IIS_IUSRS).
Also once you have created the user, you will want to give it access to your data source back-end (if sql is running on the same machine and using windows authentication to access SQL).
Check Application Pools which assign Site on IIS, probably it is stopped.