Avatar of Shepwedd
Shepwedd

asked on 

How do I use query string variables to pass data from a database to an asp.net visual c# web site?

I have written the attached code to identify a users login details. I next want to pass in three query string parameters: Database details (from a connection string), a document number from the database (int) and a version number from the database (int), however I only want the information to be available to the user if they have sufficient permission, hence obtaining their login details.

Thanks.
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Security.Principal;
using System.Runtime.InteropServices;
using IManage;
 
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Pull back current users login details and show in a text box
        //TextBox1.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
 
        //Pull back current users login details and show in a text box, but only in this particular section of code which is before the undo statement
        System.Security.Principal.WindowsImpersonationContext impersonationContext;
        impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
 
        WindowsIdentity currIdentity = WindowsIdentity.GetCurrent();
        string NtAccountName = currIdentity.Name;
        TextBox1.Text = NtAccountName;
 
        impersonationContext.Undo();
 
    }
}

Open in new window

.NET ProgrammingASP.NETC#

Avatar of undefined
Last Comment
Shepwedd
ASKER CERTIFIED SOLUTION
Avatar of i_love_programming_08
i_love_programming_08
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Shepwedd
Shepwedd

ASKER

Thanks
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo