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

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.

Related

Localization for user profile information Asp.net

I'm trying to implement page localization to my webpage made in asp.net-mvc. I understand how to implement titles and other modular data.
The problem comes when i want to give user/admin of this page rights to change his personal information/bio on her webpage if needed. Do i save the bio in the database? With another column in the table which indicates for which language it is meant?
Or is there any better solution?

Sharepoint form writing to sql database

I want to build a form that will edit a table on SQL server. I known how to do it in ASP.NET (I need two drop down lists, gridview and button) but I want to make it as a part of SharePoint.
Can someone tell me what is the best technology to do that, I was looking at InfoPath but it seems I can not run it in web browser (only InfoPath filler). I just want to build simple form that is a part of Sharepoint and that is working in web browser. Please help.
Best regards
Daniel
One easy approach to read/write from/to SQL databases in SharePoint is to sync the external data with SharePoint lists. In this way you have the full feature set of lists available with best performance and highest security. Users are just working with a synchronized copy of the external data in the lists. To sync the data you can program by yourself, use PowerShell or 3rd party sync tools like the Layer2 Cloud Connector.
It is not a best practice in SharePoint to directly change the database.
One way you can do is Connecting to SQL Server Using the External Content Type Feature
http://www.dotnetcurry.com/sharepoint/794/sharepoint-2010-connect-sql-server-external-content-type
If you want to change directly , As you already know how to do it in Asp.net , you can go for Visual Webpart with same asp.net gridview and connection string

Visual Studio MVC Web App user data

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.

How can I post a variable from one page to another, completely different page?

So I have an ASP.Net website. I'm trying to make it where the owner of the website can change a portion of her website that is just text. I was thinking to make it a string variable that she can change on one part of the website and it posts on the other part. I tried looking at [this page](http://msdn.microsoft.com/en-us/library/vstudio/ms178139(v=vs.100).aspx"A link to Cross Page posting with ASP.Net Webpages") and the directive it tells me to include isn't recognized. I can get the variable to change and display on the page I changed it with, but have no idea how to make it to where I can use it on another page.
In order to have changes maintained across sessions and application restarts the data will need to be written out to persistent storage. Typically that would be a database, or for simple systems, one or more files.
If you are going allow modification of the site then there are security concerns. A common scenario would be to have an administrative login that allows access to the underlying data.

Sharepoint connect to another SQL server?

Here is the task I'm checking:
1) have a product database, which is managed by another application (it has no relation with sharepoint).
2) now, my boss want to have an application within the sharepoint portal to search this database, plus, audit the searches, i.e. who searched what at what time....
There is no problem if this is a regular asp.net application. But, what's the best way to do this in sharepoint?
My plan is to:
use team site template (or blank template), create a webpart. then have UI, and gridview to show the result.
is this the way to do? I try to find an example of using gridview in webpart, but cannot find it. Is there any limitation of using asp.net control in webpart? what about use ajax toolbox control in webpart? any example?
thanks
Roughly there are 2 approaches you could go for:
The webpart approach, just as your describe it. You can use an ASP.NET gridview with no problems in your webpart. As such, a webpart is nothing more (simplified...) than a user control with some dress up.
Go for BDC/BCS. This will allow you to consume the external database and show the information as be it 'native' SharePoint data. This has the added benefit that the content can be made searchable from within SharePoint. Using this approach you also do not have to create a UI to present the data, as SharePoint will present it using the out of the box view pages, etc.
The downside of the webpart approach (option 1) is that if you have multiple front end servers in your farm you need to handle the session in a way (e.g. by setting up sticky sessions on your loadbalancer, or by sharing your session somewhere centrally (in a db for instance)), as you don't want users to switch between servers in one session while they are using your webpart probably.
The downside of option 2 is that at first it might seem complex, but let that not scare you away :-)
http://msdn.microsoft.com/en-us/magazine/ee819133.aspx
You should code this as one or several web parts. You can use pretty much any asp.net controls in web parts. If you want to use any third party tools like DevExpress you must ensure that the binaries are strongly typed so that you will be able to register them in web.config, note that the registration can be done by the wsp deployment if correctly configured.
Web parts behave as any .net code except for the fact as I mentioned all references assemblies must be "safe".

Categories