|
there some another sites are published in the same IIS, they all working fine
|
|
|
|
|
Using Forms Authentication and locking down the path so you need to be authenticated to access the pages / data.
I am trying to use the current authenticated user credentials in order to process a web request within the .aspx page that the user has navigated to. Code as below:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
req.Credentials = CredentialCache.DefaultCredentials;
WebResponse res = req.GetResponse();
NOTE: the uri is valid.
The response is a redirect to the login page (bad credentials redirect to login page) and not the requested data provided by the web request.
I am struggling to find what I need to do in order for this request to be processed as though it was the current authenticated user.
Any advice is most appreciated.
Thanks in advance.
Ant.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return!
- David Walliams (Little Britain)
|
|
|
|
|
Forms Authentication works (by default) by storing an encrypted ticket as a cookie upon login, which the authentication module then reads and interprets to determine the currently logged in user.
For the situation you describe to work (if I am not misunderstanding you), the uri that forms your HttpWebRequest needs to either be in the same web application (which would be very unlikely) or it would be to a web application that is configured to use forms authentication with the same machineKey as the calling application. Configuring multiple applications with a common machineKey in web.config is one way to achieve single sign-on, allowing the user to have one login that passes through to other applications. You can read the following article, under "Web Farm Deployment Considerations" to see how:
http://msdn.microsoft.com/en-us/library/ms998288.aspx[^]
There is also a bunch of blog articles describing single signon you can find by googling "asp.net forms authentication single sign-on"
Then from the calling application it would be a matter of adding the forms authentication cookie that has already been created (again through the successful submission of a user login form) to the request object's CookieContainer[^] prior to making the call. If the target application is configured correctly, it will automatically interpret the cookie and the forms authentication credentials to determine the user.
|
|
|
|
|
Many thanks Mike, getting the cookie and adding it to the request CookieContainer is exactly what I wanted.
Just for others to reference I have included my code.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
HttpCookie cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
Cookie authenticationCookie = new Cookie(FormsAuthentication.FormsCookieName,
cookie.Value,
cookie.Path,
HttpContext.Current.Request.Url.Authority);
req.CookieContainer = new CookieContainer();
req.CookieContainer.Add(authenticationCookie);
WebResponse res = req.GetResponse();
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return!
- David Walliams (Little Britain)
|
|
|
|
|
I'm glad, Ant. Nice code snippet too.
|
|
|
|
|
|
Hi,
if you have an ASP.NET button you can register for the click-event of the button. Within the event handler use Response.Redirect to navigate to the other page.
|
|
|
|
|
if the application is xbap application which has been published and has its url . Can it be done the same way . If not then how?
|
|
|
|
|
So is the calling app an xbap app or the is it the page you want to navigate to?
If you want to navigate to an xbap app it should work without problems (only in IE). If you want to do this in an xbap app you should post the question in the XAML/WPF forum, maybe someone would know this over there.
|
|
|
|
|
This [^]link explains quite a few methods to do this.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Im using this code to get and display FullNAme from Active Directory.
It works fine on my machine but when i upload it on the Server It give me following error
I try to change winNT into LDAP but no use on SERVER...
////////////
Error: System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.PropertyValueCollection.PopulateList() at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) at System.DirectoryServices.PropertyCollection.get_Item(String propertyName) at _Default.GetFullName(String strLogin) in d:\inetpub\En.ASPETAR.Rel\QCD-Suggestions\Default.aspx.cs:line 60
//////////
protected void Page_Load(object sender, EventArgs e)
{
this.lblDOS.Text = DateTime.Now.ToShortDateString();
tbName.Text = GetFullName(Request.ServerVariables["LOGON_USER"].ToString());
}
private string GetFullName(string strLogin)
{
string str = "";
// Parse the string to check if domain name is present.
int idx = strLogin.IndexOf('\\');
if (idx == -1)
{
idx = strLogin.IndexOf('@');
}
string strDomain;
string strName;
if (idx != -1)
{
strDomain = strLogin.Substring(0, idx);
strName = strLogin.Substring(idx + 1);
}
else
{
strDomain = "MYDOMAIN NAME";
strName = strLogin;
}
DirectoryEntry obDirEntry = null;
try
{
obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/"+ strName);
System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties;
object obVal = coll["FullName"].Value;
str = obVal.ToString();
return str;
}
catch (Exception ex)
{
str = "";
return "Error: " + ex;
}
}
sheeba
|
|
|
|
|
What exception are you getting ?
And how does it related with ASP.NET ?
|
|
|
|
|
Error: System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.PropertyValueCollection.PopulateList() at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) at System.DirectoryServices.PropertyCollection.get_Item(String propertyName) at _Default.GetFullName(String strLogin) in d:\inetpub\En.ASPETAR.Rel\QCD-Suggestions\Default.aspx.cs:line 60
sheeba
|
|
|
|
|
This is the Stack Trace. There should be an error message
|
|
|
|
|
i want to create a floating form in my web forms.
a floating form with out windows frame and with close button and it should be movable... im looking for javascript code that use it in asp.net...
help me please...
thanks
M.Alizadeh
|
|
|
|
|
If it doesn't have a frame, javascript can't help. You'd be creating a floating div.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
tel me please how i can use a floating div...
i dont know about this
M.Alizadeh
|
|
|
|
|
|
I need to perform a custom paging like
"First" "2" "3" "Last"
but not able to do it
my grid is binding on a button click.
pls help
|
|
|
|
|
I don't believe the gridview suports that, you'd have to write your own paging control.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
i know that gridview doesnt support
custome paging
thats why i was asking for some waythrough it .
|
|
|
|
|
Hello Friends,
I'm implementing custom paging in my GridView. Paging numbering(in-built paging numbering) does not display but it brings the records are queried . Below giving my code please let me know what changes i should make in my code. But if i use in-built paging(normal paging) then that's working fine......
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
lblMsg.Text = e.NewPageIndex.ToString();
int pageNumber=Convert.ToInt32(e.NewPageIndex);
int recordPerPage= 4;
int startRecord = (pageNumber) * recordPerPage + 1;
int maxRecord = startRecord + recordPerPage;
bindGridView1(startRecord,maxRecord);
}
public void bindGridView1(int startRecord,int maxRecord)
{
string connectionString = "server=.;database=Auto_New;uid=sa;pwd=;";
using(SqlConnection mCon = new SqlConnection(connectionString))
{
SqlCommand mDataCom = new SqlCommand();
mDataCom.Connection = mCon;
mDataCom.CommandType = CommandType.StoredProcedure;
mDataCom.CommandText = "SP_Select1";
mDataCom.Parameters.AddWithValue("@startRecord", startRecord);
mDataCom.Parameters.AddWithValue("@maxRecord", maxRecord);
SqlDataAdapter da = new SqlDataAdapter(mDataCom);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
}
|
|
|
|
|
Hi All,
I have a table with headers as below, table displyed with a horizontal and vertical scroll bars within DIV tag. When it is displayed in IE browser headers width is normal but when they are displayed in Mozilla or Safari browsers they are displayed with reduced column widths when compared with its items below.
I found the reason for this is below code(overflow: ovfl), but when I put the overflow: auto here the header widths are proper but when we scroll vertical bar headers are going inside of the DIV tag.
if(DIV_Array.clientHeight>290){$(TAB_Array).fixedHeader({width: 900,height: h, overflow: ovfl});}
Can anybody give me advice to make the headers fixed and their widths are also fixed according to the width of columns.
Thanks in advance.
This is the table header part
<th class="RowHeader2Cell1" align="left" style="white-space:nowrap;width:20%;">Asset Name</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">CUSIP</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">ISIN</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">SEDOL</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Ticker</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Current Allocation</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Quantity</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Current Price</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Date Priced</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Market Value</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Total Cost</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Unrealized Gain/Loss</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Estimated Annual Income</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Yield</th>
<th class="RowHeader2" align="right" style="white-space:nowrap;width:20%;">Portfolio</th>
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
Hi dear try this...
How to Freeze GridView Header While Scrolling ?
This is very common problem in Web development that we need to freeze the GridView header at the time of scrolling, Here is one simple tips:
Step 1 : Create a CSS class as following
view plaincopy to clipboardprint?
1. .HeaderFreez
2. {
3. position:relative ;
4. top:expression(this.offsetParent.scrollTop);
5. z-index: 10;
6. }
Step 2 Set Gridview’s HeaderStyle CssClass as follows
CssClass="HeaderFreez"
That’s all. Some times we need also maintain the scroll positions while selecting any data from GridView, and quite difficult to maintain the position while we are using AJAX, I have written a complete article on that, hope this will help Maintain GridView Scroll Position inside updatepanel
|
|
|
|
|
Hi,
I am not using gridview instead I am using table here. Still can I use the same CSS for my purpose also.
Thanks,
Md Abdul Aleem.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|