I am using nopCommerce 3.50. And trying to make it a multi storied. Every user signup here will have there specific e-commerce like nopCommerce.
Main features I have to focus is:
Every user(store owner(1 store/user)) will have their own subdomain.
user's will have full control on their store.
They can change theme or configure any settings as an admin of
NopCommerce can.
So what I am thinking to do is:
Create a new project(mother project).
Link One NopCommerce Solution with it.
when a user signup there, they create a new database as nopcommerce.
Name database uniquely for the user.
store db name and all user info in mother project.
When user sign's in, get the user db from mother db and set the path to nopCommerce Solutions db-path.
when a user logs in, user is redirected to a subdomain.
and loads the respective database for the user using same server-side and client-side code.
Is it possible or there is any other better way to do this?
Related
I am trying to create a simple login application using WPF c#. I got the login part down but I cannot figure out how to create unique pages for individual users.If user "A" creates a new account, then he should have his own new profile form. This means every time I create a new user, a new profile form is generated and that new form is assigned to the user and no other user can make modification to that user's profile. For example: Skype profile. I am sure there are questions like this floating in stackoverflow but I can't find them. I would really appreciate if someone could guide me through this.
You're overthinking the problem. The form is the same for all the users. The content of each user's form varies. When the user logs in, your database should store some variables detailing that user. Simply set the forms controls to reflect the users details. Don't "create a new profile form".
I am designing an online store.
Currently I am using AspNetSqlProfileProvider & Simple Form authentication to implement my Cart which works completely fine!
But the problem occurs while the anonymous user signs up and a new profile is created. Then the old cart content (as anonymous user) is not migrated into the new profile.
Based on this link I used Profile_OnMigrateAnonymous event in global.asax in order to transfer Profile Data from the Anonymous User Profile to The Registered User Profile.
As I searched for this issue I found that CommonProfile is not accessible within the Web Applications, so I cannot use Profile.GetProfile(args.AnonymousID)
Besides, I don't want to use ASP.NET MembershipProvider.
So, how am I supposed to get data from AnonymousID?
I am developing an application in asp.net using vs2010.
In application, Admin can create different user accounts using Microsoft member registration wizard.
Users can Login with created credential using Microsoft login control.
Now,I have to access this Logedin user's UserID and UserName in entire application's different forms.
Currently I am accessing this details by writing code in all forms by
MembershipUser newUser = Membership.GetUser();
Guid newUserId = (Guid)newUser.ProviderUserKey;
So, where can i store this login user's UserID and UserName in a common place. So I can access this details from common place?
Please Help me.
Thanks,
Well - that depends fully on where you persist the data for your application.
If you use a database for storage, then logically the data should belong in there, in a user table, with a connectionstring to the database in your application's configuration.
If not using databases, then you properly need some file based storage, for example XML or something you invent yourself and then have a parser which serialize/deserialize the data from files.
In both instances, you'll need to consider security and hashing/salting and make sure the data is kept secure.
I tend to use a static helper class, which stores (and loads) data in HttpContext.Items for the duration of any request. So you would just need to call GetUser once per request. If even that is too much for you, you can use a Session, for example - but don't forget that sessions only live for so long, so be prepared to reload the data if it's lost due to session timeout.
The static class has to be somewhere accessible from the whole application - in a web site project, this means the App_Code folder.
I am new to MVC and actually new to web development all together. I have about 7 years of development experience but in services, database, object models, etc.. basically middle-tier and back-end development. I am trying to learn ASP.NET and decided to build a site using MVC3 for a personal site for myself. I will be hosting this from an account at dotnet-hosts.com. Here is my question... I don't have a domain and I will be using the built in membership provider. I noticed in the auto generated code that was created when I added the project template that in the AccountController in the method ChangePassword (ChangePasswordModel model) there is this line of code...
MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
My question is specifically around User.Identity.Name, this looks like it would be returning the Windows user name just like Environment.UserName would. The Visual Studio template I used is the (Mobile Ready HTML5 MVC.NET) as I want to be able to support clients from any device...Windows PC, Apple, Windows Phone, iPhone, etc... If the call to User.Identity.Name is correct then I would like to ask how does this work on devices that are not Windows like an iPhone? If my assumption is correct that this will only work for Windows computers with a domain then how can I achieve this? would I need to perhaps use some caching? If so could I maybe grab the user name and their IP address to be used as the cache key from the Authentication page?
My high level question is... How do I get the current logged in user's userName regardless of the device/platform? I know this question is probably not written well and may be hard to understand... I apologize for that. I am new to web development and trying to get my feet wet and would like to start to the latest technology.
The call is correct. The User.Identity.Name is filled out by whatever authentication provider is in use - Windows authentication, Forms authentication, some custom authentication provider, or whatever. It isn't bound to a specific user "type". The authentication provider has the responsibility of making sure the Identity object corresponds to the current user on every request. Usually that part is taken care of using a combination of cookies and database.
The MVC template (although I haven't had a look at the template since MVC 2) uses ASP.NET's Membership class, which in turn uses a membership provider - for example SqlMembershipProvider or ActiveDirectoryMembershipProvider - the former stores your users' credentials (username and password etc.) in an SQL Server database, the latter uses Active Directory (i.e. primarily Windows logons). SqlMembershipProvider is the default, and MVC is set up to use a local SQLExpress database file as its user store.
The authentication provider that's implemented in the template project uses FormsAuthentication, which does the login procedure through a simple HTML form (the one in the LogOn view) and keeps the user signed in by way of an encrypted cookie. Works on any platform.
The setup for both FormsAuthentication and SqlMembershipProvider can be found in web.config (the one in the root of the site). There you can find the connection strings for the SQLExpress database (and e.g. change them to use a "real" SQL Server if needed), the timeout for logins etc.
(Note that you can do a lot of that configuration easily in a GUI through the "ASP.NET Configuration" button in the toolbar of Solution Explorer in Visual Studio - it also provides an easy way to set up the first users).
In short, it's all ready to go - and doesn't lock out non-Windows users.
Like you said User.Identity.Name is indeed correct. for returning the logged in users name. But the membership section like you said, provides only windows accounts. You can use similar without the user of windows accounts, to work in every scenario, and can still verify against windows if present. If you call it without membership, and follow the default MVC3 template it should work fine.
String Username = User.Identity.Name;
When you log on, using the template MVC3, it creates an authcookie. See account controller code. Here, two parameters are passed into it. The username, and to persist (when browser is closed - login is still cached).
The username is a string field, which is what is called by User.Identity.Name and infact, anything can be put into it, and is not in anyway linked to Windows login.
You could test the login via method you desire, and if yes, set a cookie using the authcookie method. (its encripted). And set the username to what ever you want. And if your verification of the user fails, dont create one, and redrect back to page.
See the example code. This is all from memory, as I dont have code infront of me for reference. But its all in the account controller, Login Action.
When the cookie is set, The users login state is cached for the session. You will need to ensure the user is logged in when visiting a webpage. Otherwise loggin in will be pointless. This is a simple attribute on the controller/action.
Note: dont do this to the Account/logon controller, as you wont be able to visit the logon page, as you are not logged in.
[Authorize]
public ActionResult DoSomething()
{
// ...
}
Hope I have helped.
I have installed a Login control in ASP.NET/C# in login.aspx and after the user has logged in, it takes him to the member.aspx page. All works perfectly fine but what should I do if I want to query a database for some user-specific data? How would I do that?
ASPNETDB.MDF is the database, I have created another table with some additional fields for the user.
So after the member.aspx has been loaded I put a LoginName control so extract the user's name but how can I use this to query the database for some info?
I tried calling the database with owner user/pwd but it doesn't work. It says "Login failed for ". Is there any other way of doing that?
Basically I want to show data to the user in a gridview so the user can edit it.
Since you are already using the ASP.NET login system, you could take a look at the Profile system.
You can use profiles but if you have more spefic requirement then you can inherit the login control and create your controls.