Configuration :: Different Web.config Depending On User Logged In?
May 19, 2010
I've an application only used in my site, and I'm interested to put in production from a global scope and the same instance to all the sites.
The fastest solution I've in mind is to use the current database for each different site, as copy from current system and add/clean a new one when a new site will start using it.
For this purpose I though in a front database where to check the logged in user site and then, depending user configuration, access his own site database.
I'm using now a connection string called ConnectionString1 in all the controls/code-behind database access. Then, my trouble is how to make it configurable to point to a certain database with the same connection string name but different connection string value depending on the user who has logged in, in order to not modify the current code I did. The only work I must do is change LogIn page to select appropiate database to access.
I'm writing an application that will be accessed by different groups of users. I have one aspnetdb for logon; then depending on which group a user belongs to, I want to point them at a different 'content' database. Each user wants similar information, but unique to each group, so the schema of each database will be the same, but the content will be different. We're probably talking a dozen or so groups here.
What's the best way to achieve this? Would roles do? I could put each user into a specific role, group1, group2 etc, then check which role a user was in and use a connectionstring in the web.config file based on that. This seems like it would work, but it seems a bit of a cludge. A dozen or so connection strings doesn't seem too much of a problem, but it doesnt' really seem the correct use for roles.
I have a web application that initializes a third-party com application to perform few calculations. The website is deployed on a windows 2008 server (standard edition).
The problem I have been facing is that when I am logged in to the server (Remote Desktop Connection only as the server is not local), the com application initializes fine. But when I log-off or just close the remote desktop connection, the application doesn't get initialized. I have searched for a solution and found this: [URL]
I created the scheduled task as I didn't know how to create the windows service (the description at http://support.microsoft.com/kb/251192 is too confusing), and got the application to run when windows starts before even the user logs-in. But in even in this case, the application doesn't work unless the user is logged in and when I log-in, a second instance is created (with exactly the same user (admin)) and the original instance is never used.
I cannot get the application to run without logging off or atleast having to close the remote desktop connection.Is there anything I am doing wrong?
I have a really weird problem that I've been investigating for at least one week now. I deliver a website hosting both ASP classic and .NET 3.5 content in IIS6 on a Windows 2003 server environment with MySQL db backend. The solution has been installed on several servers (some hosted in WMWare) with no problems. On one specific server, also hosted in WMWare, the user experience great performance issues on the website. The problems are most seen when using database resources and is not limited to either .net or asp classic, but I am still not sure that the problem is only related to database calls.
Following components are involved:
IIS6 .NET FW 3.5 MyODBC 3.51 / 5.1 MySQL 4.x
Code executed on the server using all resources above runs smoothly when the IIS is not involved. The website shows times up to 2 minutes to execute code that takes 2 seconds outside the IIS. The exact same code is executed. Using profiling tools, I've seen that the great loss comes within calls to unmanaged code, for example when System.Data.ODBC namespace to calls into myodbc.dll.
The tricky part is: If at least one console user is logged in to the server, the performace problems are not seen anymore. When the user logs out, the problem appears again.I have tried to reinstall all components above, tried different versions of MyODBC, tried different website authentication methods, tried to run website under administrator privilegies, installed various MS KB's with no success.
I am in the process of moving all of the images in my web application over to a CDN but I want to easily be able to switch the CDN on or off without having to hard code the path to the images. My first thought was to add an HttpHandler for image extensions that depending whether a variable in the web.config (something like ) will serve the image from the server or from the CDN. But after giving this a little though I think I've essentially ruled this out as it will cause ASP.NET to handle the request for every single image, thus adding overhead, and it might actually completely mitigate the benefits of using a CDN.
An alternative approach is, since all of my pages inherit from a base page class, I could create a function in the base class that determines what path to serve the files from based off the web.config variable. I would then do something like this in the markup:
<img src='<%= GetImagePath()/image.png' />
I think this is probably what I'll have to end up doing, but it seems a little clunky to me. I also envision problems with the old .NET error of not being able to modify the control collection because of the "<%=" though the "<%#" solution will probably work.
I need to set my logged in time in web.config but I do not know how? I get logged out after a while if I do no do anything in the website but I wanna be logged in for 120 minutes.
I would like users to upload a profile picture when they register, and to then show that picture in a picture box control when they are logged in based  on that specific user.
I deployed a website where a logged user or an anonymous user can select data and download a XML file. The website generate the XML file in the server and then deliver it.
It works fine in my development environment, but after deployment, the anonymous user can download the file, but the logged user receive this error:
System.UnauthorizedAccessException: Access to the path 'd:HostsLocalUserheringerwebsiteUpload20110107094051.xml' is denied.
It is weird that as anonymous i can do it.
The website server help states this:
"Grant write, modify, delete access rights on website's folder
Your website executes under unique user account that by default has full control over the website's folder. So your application can create, open, read, write and delete files and folders inside of your root folder.
There is no need and no way to change this permissions.
If, when running ASP.Net application, you still unable to create file or update it, you have to check your Web.Config file for "<Identity impersonate..." tag and remove it.
The only exception is when the application tries to modify a file or folder in "Application_Start" event of Global.asax file. This is by design that user authenticated only after the Application_Start even. Before the user is authenticated your website runs under an identity of Application Pool which is "Network services". That account doesn't have access to the folder of your website.
To make it work you eather have to move the code that tries to modify files or folders out of the "Application_Start" event of the Global.asax file or inside the event you'll need to impersonate your user by code."
But i am not using impersonate and the tag is not in my web.config.
I have the membership provider and the create user with tow steps, one of the steps contains a custom registration form, for each created user data will be in the database, and there is an account page shows the data that the new created user did insert during the registration process on the custom registration page,
the problem, when the user is created and logged into his account page, this account page shows only the information for the first created user, not the info on the logged in user , but the logged in user data still saved in database and not showing on his account page?
in MyWeb there are all the aspx page and some entites datamodel, in MyApp there are the class with function like "getter data from DB" and there is a entity data model.
afeter the deploy, I have only the web.config and the connection string for the entity datamodel....it´s run ok, read/write the data on the DB.
The problem is with MyApp.....after the deploy it is a dll file and I don´t have the app.config and the entity inside it don´t run, not read/write nothing on the DB.
There aren´t error or messager but not read/write the data in the MyApp project.
all run on the iis 7
now...the question is:
I lose the connection string (in app.config) after the deploy?
Can I put a entity in the MyWeb and read it in another project (myApp)?
I am developing web applicaiton. I want to read web.config in App.config file. I have appSettings and connectionStrings in web.config. How to read that?
I have table called ROLE with fields (id,name,permission) example values (1001,madhu,hr)
I have another table called LOGIN with fields(id,DOB,password) example values(1001,24101989,madhukumar)
What i want is , if i login using the LOGIN table ,it  check the  id and permission in the ROLE table , if the permission is 'hr' it enable to access the menu , or if the permission is any other it just print the error message ("no permission")
Note: menu is placed in master page , but login is not in the master page ...
I've made a membership by create user wizard. everything is good but after click on finish register button, when page redirect to index .aspx, this page thinks tht user logged in. whereas user didnt login just added to DB.here is the code:
While using a third party dll I was getting the following exception - "exePath must be specified when not running inside a stand alone exe" with following trace
The reason I found was that it was looking for app.config and I had provided the details in web.config. My question is why does the system.configuration differentiate between web.config and app.config.
I upgrade my application from .NET 2.0 to .NET 4.0. Everything went smooth, with very few errors. Now the code is compiling fine, but run time environment is loading the configuration parameters from app.config instead of web.config;Here is my setup:Objects project: has app.configUI project: has web.config, When I run this site, it is fetching the configuration parameters from app.config. Any idea if I need to make any changes to read it from web.config instead of app.config? It used to work fine in my previous environment.
I would like to change the logged in user to another user temporarily to do some process.
For example, say I am logged in as "Joe". In my method, I want to make the logged in user from "Joe" to "SuperUser", do some process, then change the logged in user back to "Joe".
Access to my application is controlled by user accounts. I would like my text labels to change within my pages depending on the user logged in. This needs to be easily managed.
What is the best way to achieve this? Would using the resources file work?
My scenario is a 3-Tier app where the data tier is a SQL Server database, the middle tier is a WCF application hosted in a Windows Service and finally the presentation is an Asp.Net MVC application.As usual, the middle tier is the one that performs all of the business logic. Access database, define business rules.. etc. BUT now here's question: How do you handle security in such a scenario? I mean, the user has to log in on the ASP.NET application, but I want to authenticate it not only in ASP but in the WCF middle tier as well, since a WCF service is supposed to be accessed by more apps.
I want the user to log in on the Asp.Net application and let WCF know the credentials as well. Is there some kind of session in WCF in which to specify a logged in user? How do pros handle security in this case? I know you can secure the WCF services with message security, but how do Asp.Net and WCF sync on a single logged user? I want to secure WCF operations depending on the user for authorization means.
Lets suppose my application is deployed on a server located in USA. Now if any client visits my website from anywhere and from any device e.g Mobile , iPad , Surface or Laptop. Now if i want to save his local time then what should i use ?
DateTime.Now;
or
TimeZone curTimeZone = TimeZone.CurrentTimeZone; var yourTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById(curTimeZone.StandardName));
I built my ASP.NET website using vs2008 professional.
Now I have purchased vs2010 professional edition.
I do format my computer and then installed vs2010.
Now I want to deploy my website in vs2010, but it is giving configuration error in <add assemblies...
Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
I am currently using the built in ASP login function... the destinationpageurl of that login function locates to "loginhome.aspx" for all users... but for one specific user ("Admin") it needs to link to "adminhome.aspx"... just wondering whats the best way to do this? Can I change the destinationpageurl of the login function depending on the user or creating an admin role so "If membershiprole = 'Admin' redirect to 'adminhome.aspx' End If" or can I just add some code behind the login function so "If User.login.Name = 'Admin' Then destinationpageurl = 'adminhome.aspx' End If" think I have already tried this on the login1_authenticate event but it didn't work
I´m building a website and i need to store somehow some informations that i will use in the whole site depending of the user type logged in.3) Store those 2 or 3 fields that i will get in Database in a persistent way to use it in the whole site.My question is: Whats the best practices to do this?