Subit ASP.NET WebForm to ActionHandlers

G

Guest

Hi,

Good morning. Iam currently working on a J2EE to .NET migration project where i have to implement the java technologies that are used in the application to the equivalent .NET technologies. I have a very seriously troubling query to solve in the application. Iam implementing the Java Struts thru HttpHandlers(web.config) in the application. For this iam using the Web.config where iam specifying the action handlers for the web pages that I want to handle. Now, my problem is that, iam submitting the login form which will redirect(I have used Response.Redirect as Server.Transfer is giving an error while redirection to the specified action handler) to the action handler class on submission and iam trying to read the form elements(thru getting the Request object from Context object which it comes as a parameter to the handler class). But it is not giving the values for the submitted the login form. Iam getting the null values. What is the reason behind this? If iam using Server.Transfer then it is giving an error while redirection to the action handler. Request.Redirect is working fine, but iam unable to read the values of the submitted form. My source code is as below:


Login Page: (Login.aspx) - I have removed the unnecessary design elements and jst given the form elements for reference

<hrml><body leftMargin=0 topMargin=0 MS_POSITIONING="GridLayout"><form method=post runat="server">

Login :

<asp:textbox id=PasswordTag6 Runat="server" TextMode="Password" MaxLength="64" CssClass="skb_query"></asp:textbox><br>

Password :

<asp:textbox id=PasswordTag6 Runat="server" TextMode="Password" MaxLength="64" CssClass="skb_query"></asp:textbox><br><asp:button id=btnSubmit runat="server" Text="Submit" Width="80px" Height="24px"></asp:Button></form></body></html>


(Login.aspx.cs)

protected void btnSubmit_Click(object sender, System.EventArgs e)
{
Response.Redirect("ActionController.aspx");
}

Web.config:

<?xml version="1.0" encoding="utf-8" ?><configuration><configSections><section name="ActionSettings" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /><section name="GlobalForwards" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /></configSections><system.web><httpHandlers><add verb="*" path="*ActionController.aspx" type="MyActionFrontController.FrontControllerHandler, MyActionFrontController"/><add verb="*" path="*Failure*.aspx" type="MyActionFrontController.FrontControllerHandler, MyActionFrontController"/></httpHandlers></system.web><GlobalForwards><add key="globalTest" value="/FrontController/myGlobal.aspx"/><add key="error" value="/FrontController/error.aspx"/></GlobalForwards><ActionSettings><add key="/MyActionFrontController/ActionController.aspx.action" value="MyActionFrontController.LoginAction"/><add key="/MyActionFrontController/ActionController.aspx.failure" value="/MyActionFrontController/LoginFailure.aspx"/><add key="/MyActionFrontController/ActionController.aspx.success" value="/MyActionFrontController/LoginDetails.aspx"/></ActionSettings></configuration>





Action Handler(FrontControllerHandler.cs):



using System;

using System.Web;

using System.Collections;

using System.Web.SessionState;



namespace MyActionFrontController

{

public class FrontControllerHandler : IHttpHandler, System.Web.SessionState.IRequiresSessionState

{

public void ProcessRequest(HttpContext context)

{

try

{

// Get the HttpContext object for the current HTTP request.

HttpContext objHttpContext;

objHttpContext = HttpContext.Current;



// Get the Response object.

HttpRequest objHttpRequest;

objHttpRequest = objHttpContext.Request;



string username = objHttpRequest.Form["TextTag5"]; //iam getting “null†value here

string password = objHttpRequest.Form["PasswordTag6"]; //iam getting “null†value here



-------

-------

-------

}

catch (System.Threading.ThreadAbortException)

{

}

}



public bool IsReusable

{

get

{

return true;

} // get

} // IsReusable property

}

}

The action handlers are working fine and on submitting the Login page, the control is transferred to the above action handler class(FrontControllerHandler.cs), but in the execute method iam facing the problem of reading the submitted form values(User login and password textboxesalues). What I understood is that I cannot use Server.Transfer for redirection to Actionhandlers(as it is giving an error while redirection to the action handler class, FrontControllerHandler.cs), but Server.Transfer will post the form submitted values to the next program so that I can read the form values thru Request.Form[<index/name>] collection. Where as Response.Redirect is working fine in my case(i.e it is successfully readirecting to the action handler class, FrontControllerHandler.cs) but iam unable to access the submitted form values in the ProcessRequest method. This is really confusing me. Iam really struck up with this problem. Could you please let me know the solution to this. Thanking you very much in advance.

Regards,
Nagalinga Reddy Kapu
Senior Developer
Aztec Software and Technology Services Limited
# 23, III A Cross, 18th Main, 6th Block
Koramangala, Bangalore - 560 095
Phone: +91-80-5522892, Extn. 343
Email: (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,264
Latest member
FletcherDa

Latest Threads

Top