Last post Jan 20, 2016 08:43 AM by Mikesdotnetting
Dec 23, 2015 03:17 PM|Gautam Sharma|LINK
I am developing 2 websites in webmatrix simultaneously.. The login page error gives error due to the cookie "aspxauth"
In 1 website i use 10 digit number as username and in other email is used a s username.
when I login using 1 website, and try to browse the default page(after login) of another website, it throws an exception.
How to tackle this clash?
1) any solution to this?
2) its happening because i am developing 2 websites simultaneously and doesnt apply in reality..
Dec 24, 2015 10:12 AM|jkjhse|LINK
You can be clear about the exception and coding..
Dec 26, 2015 02:34 PM|Gautam Sharma|LINK
1) Create 2 separate websites in webmatrix, You may use the starter site as template
2) In one website use the Email as username
"UserId", "Email", autoCreateTables: true);
3) and in another site use it as mobilenumber
WebSecurity.InitializeDatabaseConnection("yoursitedata", "UserProfile", "UserId", "Mobile", autoCreateTables: true);
4) Run both the sites in webmatrix. Register and account in both the websites and login.
5) After login, I am trying to fetch the user account info based on the logged in user Id.
Just for example if the below code is in my layout page. It basically checks the user role and displays or hides the menu option.
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">Admin <span class="caret"></span></a>
6) if the above code is in site 1 and if you login to site 1, asp.net creates a cookie call aspxauth
7) Now if you run site 2, and directly try to access the restricted part of the site2, it is using the userid/username from the cookie and throwing an exception.
Dec 26, 2015 04:57 PM|jkjhse|LINK
That is all fine. But what is the realtion between two sites? I mean are they sharing some files? It is not clear until now how they are sharing same cookies.
Dec 29, 2015 10:47 AM|Gautam Sharma|LINK
1) Create 2 websites with register, login and roles facility/features. Register 1 or 2 users in each site and add a few roles in admin.
2) Login in the first site. dont logout, close the window
3) In the 2nd website, add any option on the home page that is visible only if the role is "admin"
4) Now, without logging in go to the page in the second website that is visible only to authenticated users.
2nd website is using the session cookie from the first website and throwing an exception that no user is present in the role.
Jan 15, 2016 10:53 AM|Abubad|LINK
Jan 20, 2016 08:43 AM|Mikesdotnetting|LINK
Give each site its own cookie name. You can do this in the system.web section of your web.config:
<forms name=".MyApp" />
The "name" attribute specifies the name you give to the cookie that's created for a logged in user.