I'm developing an asp.net web application and hosted on IIS 7.5 server. These applications are used in sharepoint 2010 using the page viewer web part.
Now I want to get the sharepoint's current user and url in asp.net web application. I checked for solutions but they all need me to deploy my asp.net web application in sharepoint 2010, but I don't want to do that.
I just want to use the page viewer webpart to get aspx pages in sharepoint.
Thanks for the response by Marcin. I tried the following code, but its not working. i jusr get the unhandled error exception:
Object reference not set to an instance of an object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Utilities;
namespace getuser
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string accManager;
SPUser user1 = SPContext.Current.Web.CurrentUser;
TextBox2.Text = user1.ToString();
string sspURL = "mysiteurl....";
SPSite site = new SPSite(sspURL);
SPWeb web = site.OpenWeb();
SPUser user = web.CurrentUser;
accManager = user.Name;
if (accManager != "")
TextBox1.Text = accManager;
}
}
}
I hosted this page on IIS and used the url in page viewer webpart to show in sharepoint 2010. I need to get the current sharepoint user ,url and need to pass query string from sharepoint url to the aspx page and should return url to sharepoint with parameters for another page.