Visual Studio MVC Web App user data - c#

I am new to visual studio and databases. I have tried to find this answer on my own for several days, but I haven't found what I need, probably because I am not using the correct terms.
Short background: I am interested in building a web app that will take user input, store it, and then display that information in charts. Of course, this requires unique user logins.
What I want to understand is how information specific to a unique user is loaded into the site. So far, I've learned to pull static data from a database and put it in the website. However, that does not tell me anything about unique users' data when they log in with their account. So, when I log in to, for example, my online banking account or a site like Udemy, what tells the site to pull only my data? What's the key to displaying just my data?
If you have a resource instead, I'd be happy to read that. Thank you.

You need some form of a unique identifier for that particular user. Whether this is in the form of a user Id as an auto-incrementing primary key, a Guid, or something else, it should be unique to that user in that particular table.
From that unique user Id you should then be able (depending on the db), to find data associated with that unique user.

Related

How do you store custom user data in asp.net?

I may be overlooking a question like this, but I couldn't find it. I have an asp.net site with C# codebehind, and I have a working means of creating user accounts, passwords, and associating other data with each user. I started this site by creating a web application, and the login/register functions were all included and work fine. I also have a database that the user can search and display data on the site (all of this also works). However, I want the user to be able to search the database for data, and then be able to go back to pages that they've saved as pages that they're "following." All I would need to store would be a unique identifier from the database to note that the person wanted to follow that page. Where would be the best place to store these values? Could I do so by saving the data in the aspnetdb database? If so, how would I write custom values in this database if using an asp.net web application?
If you're using ASP.NET's Membership feature, you'll probably want to use the MembershipUser.ProviderKey as the unique ID mentioned by #dcreight. Use it to access your own table. I would not recommend writing into the aspnetdb directly.

How to tie custom properties to a registered user in C#/asp.net MVC 4

Say there are three roles, namely:
Registered
Administrator
Sponsor
I'd like users to be able to self-register as Registered (easy enough out-of-box).
I'd like an Administrator to be able to see all registered users and check off the "Sponsor" checkbox, making the user a Sponsor.
Once the user is "checked" as a Sponsor, the Administrator should be able to add additional parameters for the Sponsor, including logo and Sponsor URL, which webpage(s) they are sponsoring, the valid date range for the sponsorship by webpage, the number of impressions and clicks, and also "paid/not paid".
I'm trying to wrap my head around Memberships and Profiles, and see how they apply to this.
Can anyone provide a general framework as to how I can properly architect this? Are there Nuget packages to do just this?
Advice appreciated.
Maybe my answer to another question will help a bit Using out of the box aspnet membership for public facing website
In Nuget - Thinktecture.IdentityModel is a way to go.
Use the table profile provider.
You can then edit the values in this table directly through a simple page.
Excluding the profile provider, is there an easy way to add custom fields to ASP.NET membership?
You can then use the web interface to assign a user to a role as an admin:
http://msdn.microsoft.com/en-us/library/t32yf0a9.aspx
Or simply code this page and use Roles.AddUserToRole
http://msdn.microsoft.com/en-us/library/system.web.security.roles.addusertorole.aspx

Display Table Data to the user in Visual Studio 2010

Because nobody answered to my previous questions I need to find a different solution.
So, if you can please help me I would appreciate it very much.
I need to present to the user that use the app some table data by his name and id.
In other words I have a table data about flights reservations that the user performed earlier.
that table contains flight reservations of all the users.
now I want that in case the user entered his user name and id I will show him all the data from the table that the columns userName and idNumber equals to his personal details.
How can I do this?
Where's the data coming from? If you're using a database, then databinding is going to be the simplest method of doing this. There are a ton of examples of databinding to a SQL database around the web. Here's one.
For showing only the selected user's data, you would add filters to the query appropriately. You can also search Google for ASP.net data binding and get a lot of examples.

Design help for a Online Questionnaire /Exam Application

I am developing a web application which will deal with online examination. The requirement is:
There can be n-number of sections in
an exam and admin users should be
able to create questions/answers and
add to an exam.
The questions should be displayed
for a certain amount of time in the
browser with timeclock and it should
move to next question automatically.
User should not be allowed to open any other instance of the browser or login from another IP if the exam is in progress.
I am seeking community vote of how would someone design the application to meet all these criterias? What patterns should be used? What components can help to reduce the development time etc..
My technology stack is C#, ASP.NET MVC or ASP.NET with SQL Server.
Thanks in advance!!!
Rather than re-invent the wheel, you should look at a solution such as the Open Source DotNetNuke and either buy/build an extension for the portion specific to your scenario.
I think for the user app, you should consider a Silverlight app as this will give you granular and secure control over the experience.
Overall the solution would be like this:
DotNetNuke provides the foundation portal/Content Management so you can create a highly customized experience around the exam experience including support for user management etc.
The DotNetNuke extension would enable authorized administrators to manage exams and exam questions.
A webservice wrapper would provide access to the business controller used by the DotNetNuke extension.
A Silverlight app would interact with the webservice to enable authenticated users to take their exams
Overall, such a solution would give you a high degree of control over the user experience while enabling you to focus time/resources that are only specific to your situation while leveraging an existing, robust and popular solution on which to build your solution.
(Full disclosure: I am one of the co-founders of the company that manages DotNetNuke. In fairness, you can replace my suggestion for DotNetNuke with Orchard or Umbraco and the solution would be equally valid.)
For the Database side of things you would want something like:
Table Exams (ExamID, ExamName) //to hold all exams
Table Users(UserID, Username, Login, Password) //to hold all users
Table OpenExams(Exam_ID, User_ID) //to hold open exams
Table ExamSections(SectionID, Exam_ID, SectionName) //to hold sections of exams
Table Questions(QuestionID, Section_ID, QuestionName, Question, Answer) //to hold questions
This of course at its most basic and only 1 approach of many. You would need to add fields where required.
As for item 2, i would probably do it in the application layer (or in VS). I dont have much experience in web dev, but i would think that ASP could handle that. For item 3, you could run a simple SQl statement to get if the user trying to access the exam is currently taking the exam.
Lets also start mapping the processes:
User:
1. User logs in (to prevent multiple exams by one user).
2. User "starts" an exam -> Time is noted on the server-side and timer triggered on client-side. User gets a dynamic exam page 1.
3. User is done with page 1, clicks next -> Ajax-reloading the page content (the questions part). Timer for page 2 is started (server and client side)
3.a) detected login from a different IP - session broken, user marked as cheater :) or the login is simply rejected.
User times out on page 2 -> the page content (answers) are automatically submited. the timers are set for page 3. user gets page 3.
User clicks finish -> the exam is finished.
Admin:
Logs in -> show "add exam" option and table of existing exams
Adds an exam - open "exam page", add a new "exam" entity
Adds a page - > new "page" entity added to this exam, questions table is loaded in the gui
adds a question -> new "question" object added to page
end page -> the page is saved. options for end exam or add page are here.
add page -> go to step 3
finish exam -> save exam
optionally mark exam as "active/inactive"
add tables with "students" and their results and stuff like that.
This needs a lot of work, but when you have this you have the idea of what you need to put in your design.

Get logged in user details in sharepoint c# webpart

After much wrangling I have a development environment for building sharepoint webparts in c#.
I'm completely new to SP development, so I haven't quite found the various API docs, so I'm hoping someone can help get me started.
Eventually, I want to write a simple web part that allows its user to display different content depending on who the current user is.
What I'd like to do first though is just build a dead simple webpart that will simply print out the current user's details - username, full name and any permissions groups that they have.
Thanks
SPContext.Current.Web.CurrentUser

Categories