In my winphone application I have a Browser control and a page with HTML form in it. Is it possible to somehow extract POST variables from control after user fills in and submits a form inside it?
Trying to execute JS and bind some events to submit button is not an option. I wonder if it can be done by using standard methods and events accessible for Browser control.
The Navigating event would be your most likely option for getting this information, but you can only get the Uri being navigated to. You do not get access to the Request object that is being sent to the server.
Related
Is it possible to run a request command on a set of multipartFile objects for a set of selected files that has been passed to an second action from an initial action that received them from an type file input html tag.
I can access the multipartfile object as a string in the redirected (second) action -
Such as:
form:org.springframework.web.multipart.commons.CommonsMultipartFile#35d79259
But I am unable to run a request command such as request.getFiles - also I cannot cast it as a MultipartFile.
The redirect to intentional - let me explain what I'm trying to do in more detail:
I have a file upload web page with an input form that sends the selected files (multpartFile objects) to the action. Prior to uploading the files from the client I want the user to have a web page where he adds extra data to each file prior to uploading (metadata tags). To do this I was going to redirect to another action that displays a web page with the list of the files (having transferred the params data that contain the files selected from the original web page to the redirected action) and input fields for the user to add tags. In short the redirect is intentional.
I guess the correct way to do this is using js on the original web page - just wanted to see if I could do it this way instead?
-mike
In general redirects use GET, so there's nowhere for the form body and uploaded file(s) to go. POST/UPDATE/DELETE actions make changes, and a redirect is typically an indication that something went wrong, e.g. something mild like a url changed (301/302), or something more serious like an authenticated user trying to access a page they have no permission for, or an unauthenticated user trying to access anything guarded (401/403).
You wouldn't want to pick up where you left off from a lot of scenarios that trigger a redirect (and it wouldn't be practical at all) so it's common to not attempt to do anything with form or file upload data and let the user re-do the action.
In my Web Application I have jqGrid and other struts2 jquery plugins , now what i want is to have have a global error handler function that will redirect to my index page if error occurs any idea how can I implement this functionality.
You can use Interceptor to manage your exception on application level. Also see this document for exception-handling in struts.
You can also use global-results to fulfill your needs
If you handle exceptions by redirecting to index page it will only behave in desired manner when request are generated by browser directly rather than Javascript asking browser to generate request using Ajax. e.g. by clicking on anchor tag or directly accessing application through URL. In these conditions only you will get redirect to index page.
Ajax is used to send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page on client side. Javascript responsible for calling Ajax has to handle response from server. So you have to manually trigger redirect. Have a look at this related Question.
I have one web application running on Struts. User is hitting below url directly from browser -
http://:/Test/servlet.do?name=XX&address=YYY
By default this request is submitted as GET by the user. Now my question is
1) how do I change user request to POST?
Use JQuery post or ajax methods, using an empty form with hidden keys.
There are plenty of browser add-ons that will let you send your request as POST (such as DHC by Restlet and Advanced REST client for Chrome)
Remember GET is inside the ans is set into links. POST are usually done by , or GET is possible too. So hitting a URL or link as you said is not possible to do over html, use PHP or Jquery so have it GET instead .
We need to post from data to a partner who is providing a service to us. We want to do this via a form post to keep things simple.
We will post form data (an id) to a form on the service providers website using JavaScript etc.The service needs to take this id and show some associated data to the user. We pictured this posting to a form on their server and then displaying the result in a popup. If the user is happy with the associated data they will hit submit on the form in the popup (which is on the service providers server) and the service provider will post to a controller on our server.
User clicks link on our website
This posts data to the service providers site and displays content from service providers site in a popup/iframe
User checks the data displayed in popup and sees they are happy with it
The user hits submit in the popup (service provider updates something on their site)
Service provider submits form data to our controller (we update something on our site)
We need to make sure that only our server can post to their page and only they can post to our page.
We are using MVC3. They are using a web technology of their choice.
Any advice on the simplest quickest, and secure way of doing this. Obviously need to prevent replay attacks and be sure that they are the only ones that can post to us.
We want to do this via a form post to keep things simple. We will post
to a web page on their server, they will do some processing and post
the data back to a controller action on our server.
Ah no, that's impossible. If you have an HTML <form> whose action is pointing to some url (no matter if this url is located on your server or on a third-party server), when this form is submitted the browser will POST to this url and redirect to it. This means that while you will be able to send the request to the remote source and it might then query some controller action on your domain you will not be able to show the results of the execution of this controller action in the browser, because the browser will show the result of the execution of this remote url.
So one technique would be to have the HTML <form> POST to a controller action of yours which itself will delegate the request to the remote service (using a WebClient) and then return some view to the user.
Now all that's left is to ask the network administrator of the remote server to allow HTTP requests only from the IP address of your web server.
Of course this is leaving the possibility for the user to craft an HTTP request to the controller action of yours and thus indirectly hit the remote service. The only possible way to prevent this from happening is to use authentication and deny public access to anyone to this controller action.
I want to differentiate between a new tab or new window request and simple request (i.e page opening in the same tab) on server or client side in MVC .net?
actually, we are nor using content placeholders in the layout page. we have div in it and child pages are loaded in it.so child aspx pages don't have Master page specified for them.
so when a new tab is opened for page, our master page is not attached to it, so all look and feel is lost.
now I want to identify a tab request #server side so as to send the required page with layout page.
I tried using Request.refferer to find the presence of master page, but the absolute URI is not always same for Firefox and IE
Current Scenario =>
1) Simple request : controller => Action => returns with Master page
2) Request generated when the user right clicks on the link and opens new tab:
controller=>ActionName => returns view without master page attached
The HTTP header fields have a fair amount of information in them, but whether or not the request originated from a new window is not included. Based on your question it sounds like you are using a lot of client side code for content retrieval and rendering - Ajax.
Assuming that is the case your best bet is looking at the nonstandard HTTP request field X-Requested-With:
mainly used to identify Ajax requests. Most JavaScript frameworks send this header with value of XMLHttpRequest
In ASP.NET MVC you can use the Request.IsAjaxRequest extension method to poke at this field. In this manner if a link is opened in a new window you can return the full page Site.Master and all. When the request is your expected behavior you'll know because it is an Ajax request.
That said, I'd recommend working on the way that you are rendering content and look up information on progressive enhancement.