Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 14th, 2007, 10:22 PM
Registered User
 
Join Date: Dec 2004
Location: Indore, MP, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default access C#.Net page as action of calssic ASP page

Hi,

I am trying to access a .Net page form as action on a Classic ASP page (both are on different domains). The sequence of the page execution is as under:

1. Classic ASP Page that accepts User Name, Password and a token number. This page is submitting twice. On first submit the action of this page is itself. It Encrypts the values and place them in hidden controls and again submits it; this time the action of this page is a C# .Net Page.
2. C#.Net page Decrypts the values and verifies the User. If user is a valid user it generates a form in it (using JavaScript) and action of this generated page is again a classic ASP page.

When I open a new browser execute the classic ASP Page. The classic ASP page submitted twice (as planed to do so). Second submit action is C#.Net Page and I get the error on C#.Net page.

I am getting this Error on C#.Net page
   "Object reference not set to an instance of an object. "


The magic begins here. When I click on back Button of browser the classic ASP page gets submitted again (because it has the true condition for second submit) and this time it works fine and I got the expected results. After that If I continue with the same browser window for other user verification; it works fine through out. But again if I use a new browser window it gives the same error first time.

I have checked all controls names, values and form generation condtions; but not getting why it is happening. Please help me out.


Thanks & Regards
Manish


  #2 (permalink)  
Old October 15th, 2007, 08:20 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What are the details of the code that is crashing? Is the .NET code using session values that aren't there on the first hit?

It sounds like you are creating a remote authentication type system. Instead of making several round trips between server and client, perhaps you could simplify this process with a single call to the target server doing the authentication. Seeing as you are in ASP, you could use the XmlHttpRequest object that should be available on your web server to make the request to the other server instead of using several auto posting forms.

-Peter
  #3 (permalink)  
Old October 17th, 2007, 10:53 AM
Registered User
 
Join Date: Dec 2004
Location: Indore, MP, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Thanks Peter,

sorry for late reply. No I am not using session values, I am using textbox ( the input tag ). and here is the error as it appear on the screen:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
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 reference not set to an instance of an object.

Source Error:

Line 21:
Line 22:
Line 23: un = Request.Form["username"].ToString();
Line 24: ps = Request.Form["password"].ToString();
Line 25: tkn = Request.Form["ltoken"].ToString();

Source File: Authenticate.aspx.cs Line: 23


First time I get this error. I click on back button; the ASP page gets submitted autometically and the C# page loaded second time and I get no error this time.


Thanks
Regards

  #4 (permalink)  
Old October 18th, 2007, 01:11 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

That is strange indeed. I can't imagine why it's behaving the way you describe.

Perhaps you could use a tool like Fiddler to debug the HTTP activity and see what is actually getting posted to the .NET page each time.

-Peter
  #5 (permalink)  
Old October 23rd, 2007, 01:03 PM
Registered User
 
Join Date: Dec 2004
Location: Indore, MP, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Thanks Peter

I tried everthing I can including debugging but no luck. It works fine with QueryStrings so I Implemented it with QueryStrings for right now. Hope I get some solution in near future. :)

Thanks and Regards
Manish

  #6 (permalink)  
Old January 3rd, 2008, 08:50 AM
Authorized User
 
Join Date: Jul 2007
Location: Bangalore, Karnataka, India.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mujahidkhaleel
Default

You cannot do POST to a ASP.NET page from ASP. The ASP.NET page will not find the server side controls and thus not allow POST values.

Alternate is to have the form in ASPX page and then redirect the successfully validated user back to ASP page.

Mujahid Khaleel
Web designing, development, E-commerce applications.
  #7 (permalink)  
Old January 7th, 2008, 10:58 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by mujahidkhaleel
 You cannot do POST to a ASP.NET page from ASP. The ASP.NET page will not find the server side controls and thus not allow POST values.

This is not true. You most certainly can post any html form regardless of where it comes from to an ASP.NET page. Yes, the ASP.NET page will not find control instance values from the posted form, or at least they won't be valid if they are there, but you can access the raw form as this use is demonstrating. You'll need to know the form fields (such as the hidden fields in this case) and you can get their values from the forms collection just like we would in classic ASP.

What the OP is trying to do should work, but isn't.

-Peter
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET - Static Page and Dynamic Page sohrabus ASP.NET 2.0 Professional 2 April 18th, 2007 11:42 PM
Refreshing a page based on action in pop-up nkrust ASP.NET 1.0 and 1.1 Basics 4 January 15th, 2007 04:21 PM
Access Master page control from Content page. angshujit ASP.NET 2.0 Basics 3 January 11th, 2007 06:20 AM
how to access the uri of the current asp.net page connect2sandep ASP.NET 1.0 and 1.1 Professional 2 November 1st, 2005 07:13 PM



All times are GMT -4. The time now is 04:04 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.