Monday, March 26, 2012
Please help - Passing credentials to windows integrated authentication
authentication turned on.
I use System.Net.Networkcredentials as well as System.Net.Webrequest and
Webresponse.
I receive a response but when I try to use Response.Redirect(), a popup
windows appears asking me for user, password, domain.
Is there a way to pass the credentials to the Reponse.Redirect function so I
do not get prompted for credentials again?
This is the code i use:
Dim objCredentials As New System.Net.NetworkCredential
(strUsername, strPassword, strDomain)
Dim objCache As New System.Net.CredentialCache
objCache.Add(New Uri(strURL), "Negotiate", objCredentials)
Dim objWebRequest As System.Net.WebRequest
Dim objWebResponse As System.Net.WebResponse
try
objWebRequest = System.Net.WebRequest.Create(strURL)
objWebRequest.Credentials = objCache
objWebResponse = objWebRequest.GetResponse()
'I get prompted here
Response.Redirect(strURL, False)
Response.Close()
catch ex as exception
end try
Thank you very muchNo there is not. When you use the WebRequest object on the server, the
server is making the request, passing the network credentials. When you use
Response.Redirect, you are instructing the remote client, to make another
request to the server address you passed it, strURL.
The remote user then makes the request to strURL; the browser will only send
the credentials on the machine the remote user is using. I know of no
workaround.
HTH,
bill
"jadher" <jadher@.excite.com> wrote in message
news:uZVSAz5rEHA.1152@.TK2MSFTNGP11.phx.gbl...
> I try to access an asp page in a machine that has windows integrated
> authentication turned on.
> I use System.Net.Networkcredentials as well as System.Net.Webrequest and
> Webresponse.
> I receive a response but when I try to use Response.Redirect(), a popup
> windows appears asking me for user, password, domain.
> Is there a way to pass the credentials to the Reponse.Redirect function so
I
> do not get prompted for credentials again?
> This is the code i use:
> Dim objCredentials As New System.Net.NetworkCredential
> (strUsername, strPassword, strDomain)
> Dim objCache As New System.Net.CredentialCache
> objCache.Add(New Uri(strURL), "Negotiate", objCredentials)
> Dim objWebRequest As System.Net.WebRequest
> Dim objWebResponse As System.Net.WebResponse
> try
> objWebRequest = System.Net.WebRequest.Create(strURL)
> objWebRequest.Credentials = objCache
> objWebResponse = objWebRequest.GetResponse()
> 'I get prompted here
> Response.Redirect(strURL, False)
> Response.Close()
> catch ex as exception
> end try
> Thank you very much
>
Please help - Passing credentials to windows integrated authentication
authentication turned on.
I use System.Net.Networkcredentials as well as System.Net.Webrequest and
Webresponse.
I receive a response but when I try to use Response.Redirect(), a popup
windows appears asking me for user, password, domain.
Is there a way to pass the credentials to the Reponse.Redirect function so I
do not get prompted for credentials again?
This is the code i use:
Dim objCredentials As New System.Net.NetworkCredential
(strUsername, strPassword, strDomain)
Dim objCache As New System.Net.CredentialCache
objCache.Add(New Uri(strURL), "Negotiate", objCredentials)
Dim objWebRequest As System.Net.WebRequest
Dim objWebResponse As System.Net.WebResponse
try
objWebRequest = System.Net.WebRequest.Create(strURL)
objWebRequest.Credentials = objCache
objWebResponse = objWebRequest.GetResponse()
'I get prompted here
Response.Redirect(strURL, False)
Response.Close()
catch ex as exception
end try
Thank you very muchNo there is not. When you use the WebRequest object on the server, the
server is making the request, passing the network credentials. When you use
Response.Redirect, you are instructing the remote client, to make another
request to the server address you passed it, strURL.
The remote user then makes the request to strURL; the browser will only send
the credentials on the machine the remote user is using. I know of no
workaround.
HTH,
bill
"jadher" <jadher@.excite.com> wrote in message
news:uZVSAz5rEHA.1152@.TK2MSFTNGP11.phx.gbl...
> I try to access an asp page in a machine that has windows integrated
> authentication turned on.
> I use System.Net.Networkcredentials as well as System.Net.Webrequest and
> Webresponse.
> I receive a response but when I try to use Response.Redirect(), a popup
> windows appears asking me for user, password, domain.
> Is there a way to pass the credentials to the Reponse.Redirect function so
I
> do not get prompted for credentials again?
> This is the code i use:
> Dim objCredentials As New System.Net.NetworkCredential
> (strUsername, strPassword, strDomain)
> Dim objCache As New System.Net.CredentialCache
> objCache.Add(New Uri(strURL), "Negotiate", objCredentials)
> Dim objWebRequest As System.Net.WebRequest
> Dim objWebResponse As System.Net.WebResponse
> try
> objWebRequest = System.Net.WebRequest.Create(strURL)
> objWebRequest.Credentials = objCache
> objWebResponse = objWebRequest.GetResponse()
> 'I get prompted here
> Response.Redirect(strURL, False)
> Response.Close()
> catch ex as exception
> end try
> Thank you very much
Saturday, March 24, 2012
Please help ! Server Error in Application ! Object variable or
One urgent issue in ASP.Net.
We have hosted an asp.net application in a windows 2003 server machine. The
application runs well but ONCE IN A WHILE it comes up with the error, "Server
Error in '/CreditApplication' Application."
The error details are given below.
Sometimes, when we call the URL, it takes a long to load and finally doesnt
load and comes up with this error.
I dont understand why it works some time and doesnt work at other times.
The line in which the error is shown is a function, the contents of which
are given below.
*------------
Private Sub LocContracts()
Dim OnlineConnection As New OnlineConnection
Dim Sql, SqlComm, SqlDR
Dim Branch = "ABHN"
Dim DBConnection = OnlineConnection.OnlineDBConnection
(Database)
Dim Trans As SqlClient.SqlTransaction =
DBConnection.BeginTransaction(IsolationLevel.ReadC ommitted)
Sql = "Update Applications Set ContractType = 5,Repayment =
Case "
Sql = Sql & " when (LoanAmount * 3 / 100) > 40 Then
(LoanAmount * 3 /100)"
Sql = Sql & " else 40 End "
Sql = Sql & " where BranchId in ( Select BranchId from Branch
where BranchName = '" & Branch & "')"
Sql = Sql & " And ContractType = 0"
SqlComm = New SqlCommand(Sql, DBConnection)
SqlComm.Transaction = Trans
SqlDR = SqlComm.ExecuteReader()
Trans.Commit()
SqlDR.Close()
SqlComm = Nothing
Sql = Nothing
OnlineConnection = Nothing
End Sub
*------------
I was wondering if it has anything to do with "isolationlevel.readcommitted"
The error message is given below
*------------
Server Error in '/CreditApplication' Application.
________________________________________
Object variable or With block variable not set.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object variable or With
block variable not set.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object variable or With block variable not set.]
Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object o, Type
objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
+934
Extraction.ViewApplication.LocContracts() in
D:\CreditApplication-1.0H\ViewApplication\ViewApplicationExtraction.asp x.vb:396
Extraction.ViewApplication.Page_Load(Object sender, EventArgs e) in
D:\CreditApplication-1.0H\ViewApplication\ViewApplicationExtraction.asp x.vb:54
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
________________________________________
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300
*------------
Any help would be really appreciated.
Many ThanksWhich line is 396 in your code? It's attempting to use a NULL object
somewhere. Possibly the database connection failed in
OnlineDBConnection. If this is production code, you should add some
exception handling and logging for the DB connection and execution
calls.
Also, why use a DataReader to execute an Update statement? An
ExecuteNonQuery() seems more appropriate in this case.
-Carl
Hi Carl,
Thanks very much for your reply.
I have updated my code with ExecuteNonquery().
Line 396 in my code is given below
Dim Trans As SqlClient.SqlTransaction =
DBConnection.BeginTransaction(IsolationLevel.ReadC ommitted)
As given in my post, iam getting this error only once in a while which is
really confusing me.
Regards,
Majo
"carl" wrote:
> Which line is 396 in your code? It's attempting to use a NULL object
> somewhere. Possibly the database connection failed in
> OnlineDBConnection. If this is production code, you should add some
> exception handling and logging for the DB connection and execution
> calls.
> Also, why use a DataReader to execute an Update statement? An
> ExecuteNonQuery() seems more appropriate in this case.
> -Carl
>
> We have hosted an asp.net application in a windows 2003 server machine. The
> application runs well but ONCE IN A WHILE it comes up with the error, "Server
> Error in '/CreditApplication' Application."
> The error details are given below.
Did you ever resolve this issue? I'm currently experiencing something
similar. An ASP.NET application was running fine on a Windows XP
machine. But now that we've moved it to Windows Server 2003, it
*sometimes* gets the error that you described:
System.NullReferenceException: Object variable or With block variable
not set.
at Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object
o, Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
This is while accessing a COM object. Once again, it's worked
flawlessly on XP for quite a while now, but seems to occasionally have
problems on Windows Server 2003 (maybe the operating system isn't the
main issue, but I don't know what other differences exist).
- Roger
Hi Roger,
I havent solved my problem yet.
I was wondering if it has something to do with database locks. I checked for
any locks, but couldnt find any at the time of the error.
I have no idea how to solve this problem.
Please let me know if you come across any solutions.
Thanks
majo
"rogercnorris@.yahoo.com" wrote:
> > We have hosted an asp.net application in a windows 2003 server machine. The
> > application runs well but ONCE IN A WHILE it comes up with the error, "Server
> > Error in '/CreditApplication' Application."
> > The error details are given below.
> Did you ever resolve this issue? I'm currently experiencing something
> similar. An ASP.NET application was running fine on a Windows XP
> machine. But now that we've moved it to Windows Server 2003, it
> *sometimes* gets the error that you described:
> System.NullReferenceException: Object variable or With block variable
> not set.
> at Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object
> o, Type objType, String name, Object[] args, String[] paramnames,
> Boolean[] CopyBack)
> This is while accessing a COM object. Once again, it's worked
> flawlessly on XP for quite a while now, but seems to occasionally have
> problems on Windows Server 2003 (maybe the operating system isn't the
> main issue, but I don't know what other differences exist).
> - Roger
>
Hi,
This time, I got a new Server Error
"Fill: selectcommand.connection property has not been initialized" in
another asp page. This also comes only ONCE IN A WHILE.
The error is coming in the line with "Fill" in the code given below
*------------
DBConnection = OnlineConn.OnlineDBConnection(Database)
Sql = KeyWord
Dim SqlCommand As New SqlCommand(Sql, DBConnection)
Dim SqlAdapter As New SqlDataAdapter(SqlCommand)
Dim DataSet As New DataSet
SqlAdapter.Fill(DataSet)
*------------
While linking this with my previous error " Object variable with block ... "
, I was wondering if this error has anything to do with the database
connection.
Will this happen if the asp.net page is refreshed frequently ?
Thanks in advance for your help
Rgds,
Majo
"majo" wrote:
> Hi Roger,
> I havent solved my problem yet.
> I was wondering if it has something to do with database locks. I checked for
> any locks, but couldnt find any at the time of the error.
> I have no idea how to solve this problem.
> Please let me know if you come across any solutions.
> Thanks
> majo
>
> "rogercnorris@.yahoo.com" wrote:
> > > We have hosted an asp.net application in a windows 2003 server machine. The
> > > application runs well but ONCE IN A WHILE it comes up with the error, "Server
> > > Error in '/CreditApplication' Application."
> > > The error details are given below.
> > Did you ever resolve this issue? I'm currently experiencing something
> > similar. An ASP.NET application was running fine on a Windows XP
> > machine. But now that we've moved it to Windows Server 2003, it
> > *sometimes* gets the error that you described:
> > System.NullReferenceException: Object variable or With block variable
> > not set.
> > at Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object
> > o, Type objType, String name, Object[] args, String[] paramnames,
> > Boolean[] CopyBack)
> > This is while accessing a COM object. Once again, it's worked
> > flawlessly on XP for quite a while now, but seems to occasionally have
> > problems on Windows Server 2003 (maybe the operating system isn't the
> > main issue, but I don't know what other differences exist).
> > - Roger
Hi,
I created a new virtual directory in IIS and xcopied the whole content
(which is giving me the server error)
Right at the moment when i got the server error in my initial application, i
tried the new application which was created by me and it WORKED WELL.
Does this mean, that this server error has nothing to do with database locks
or IIS ?
I think, it has something to do with concurrent connections.
Can anyone help me with the connection parameters which i should use.
Many thanks...
Please help ! Server Error in Application ! Object variable or
One urgent issue in ASP.Net.
We have hosted an asp.net application in a windows 2003 server machine. The
application runs well but ONCE IN A WHILE it comes up with the error, "Serve
r
Error in '/CreditApplication' Application."
The error details are given below.
Sometimes, when we call the URL, it takes a long to load and finally doesnt
load and comes up with this error.
I dont understand why it works some time and doesnt work at other times.
The line in which the error is shown is a function, the contents of which
are given below.
*---
Private Sub LocContracts()
Dim OnlineConnection As New OnlineConnection
Dim Sql, SqlComm, SqlDR
Dim Branch = "ABHN"
Dim DBConnection = OnlineConnection.OnlineDBConnection
(Database)
Dim Trans As SqlClient.SqlTransaction =
DBConnection.BeginTransaction(IsolationLevel.ReadCommitted)
Sql = "Update Applications Set ContractType = 5,Repayment =
Case "
Sql = Sql & " when (LoanAmount * 3 / 100) > 40 Then
(LoanAmount * 3 /100)"
Sql = Sql & " else 40 End "
Sql = Sql & " where BranchId in ( Select BranchId from Branch
where BranchName = '" & Branch & "')"
Sql = Sql & " And ContractType = 0"
SqlComm = New SqlCommand(Sql, DBConnection)
SqlComm.Transaction = Trans
SqlDR = SqlComm.ExecuteReader()
Trans.Commit()
SqlDR.Close()
SqlComm = Nothing
Sql = Nothing
OnlineConnection = Nothing
End Sub
*---
I was wondering if it has anything to do with "isolationlevel.readcommitted"
The error message is given below
*---
Server Error in '/CreditApplication' Application.
________________________________________
Object variable or With block variable not set.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object variable or With
block variable not set.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object variable or With block variable not set.]
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type
objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack
)
+934
Extraction.ViewApplication.LocContracts() in
D:\CreditApplication-1. 0H\ViewApplication\ViewApplicationExtrac
tion.aspx.vb:
396
Extraction.ViewApplication.Page_Load(Object sender, EventArgs e) in
D:\CreditApplication-1. 0H\ViewApplication\ViewApplicationExtrac
tion.aspx.vb:
54
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
________________________________________
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET
Version:1.1.4322.2300
*---
Any help would be really appreciated.
Many ThanksWhich line is 396 in your code? It's attempting to use a NULL object
somewhere. Possibly the database connection failed in
OnlineDBConnection. If this is production code, you should add some
exception handling and logging for the DB connection and execution
calls.
Also, why use a DataReader to execute an Update statement? An
ExecuteNonQuery() seems more appropriate in this case.
-Carl
> We have hosted an asp.net application in a windows 2003 server machine. The
> application runs well but ONCE IN A WHILE it comes up with the error, "Ser
ver
> Error in '/CreditApplication' Application."
> The error details are given below.
Did you ever resolve this issue? I'm currently experiencing something
similar. An ASP.NET application was running fine on a Windows XP
machine. But now that we've moved it to Windows Server 2003, it
*sometimes* gets the error that you described:
System.NullReferenceException: Object variable or With block variable
not set.
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object
o, Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
This is while accessing a COM object. Once again, it's worked
flawlessly on XP for quite a while now, but seems to occasionally have
problems on Windows Server 2003 (maybe the operating system isn't the
main issue, but I don't know what other differences exist).
- Roger
Friday, March 16, 2012
Please help me to understand COM
I just started to learn ASP.NET. I'm not familiar with Windows programming since I was using LINUX/PHP for a long time.
I have several questions, answers to which can help me better understand ASP.NET.
My first practical task in ASP.NET is to create music manager which I already wrote in PHP. It is a database that hold albums/artists/songs/covers information. There also a class that reads/write id3v1 and id3v2 mp3 tags (http://getid3.org/).
Here is the main problem. I didn't find any class for ASP.NET that could do the same but there is a project named id3lib http://id3lib.sourceforge.net/ which can be used as a COM object. I have never worked with COM before and truly speaking hardly understand how it works.
Question: id3lib project has COM object included to work with id3 tags, how can I use it in ASP.NET? Where can I find tutorials on working with COM?
Any help is greatly appreciated.
Thanks!You can still reference COM components is ASP.NET. Simply reference the COM object along with the EnterpriseServices component, and .NET will use interop to talk to the COM object. It will be a little slower than if it were a regular .NET assembly, but you can still use it.
hope this helps,
sivilian