I am developing an application in asp.net using c#. In my application there are two pages like abc.aspx and xyz.aspx. I am opening the xyz.aspx page in an iframe of abc.aspx.
In xyz.aspx page I have a asp hidden field named ht_test_access. Now my requirement is I have to access the value of that hidden field from abc.aspx directly without querystring, session, cookies etc. Please help.
You can use Button.PostBackUrl and use Page.PreviousPage to get the previous page form data. This MSDN article Cross-Page Posting in ASP.NET Web Pages explains it very well.
string text = ((HiddenField)PreviousPage.FindControl("hdnField")).Value;
Cross-page posting is similar to hyperlinks in that the transfer is
initiated by a user action. However, in cross-page posting, the target
page is invoked using an HTTP POST command, which sends the values of
controls on the source page to the target page. In addition, if the
source and target page are in the same Web application, the target
page can access public properties of the source page. As always, all
of the pages in the application can share information stored in
session state or application state.
Related
I am looking for a method that will forward my form post. I have an outside source posting me SAML, I need them to POST to my defualt page to create a cookie before I can redirect them to the page they can operate on. The issue I am having is when I redirect them to the page they can work on the form variables (post data) is lost. I can see in fiddler I am receiving their SAML in the WebForms, but when I response.redirect to the next page, the form data is gone. I understand this is because response.redirect does a get, I was wondering if someone knew of another method, or solution to this problem. Thanks in advance.
Client Posts Saml To My default page -> my default page redirects to a shopping page (because the shopping page creates a non-user cookie) -> the shopping page then redirects to a results page (the results are based off of what is in the saml). Short: I need to preserve the initial SAML posted to me across multiple pages so I can process it on my results page. I would like to continually post it to each intermediate page.
Write a POST form to the page, fill in the data, and also write some JS code that triggers a submit. For example ADFS does this with SAML tokens.
I'm looking for a built-in solution to get what pages the user has accessed through my ASP.NET application.
Here is a simple example :
Default.aspx
Page1.aspx
Page2.aspx
Page1.aspx <-- User is here
I want to get latest page before current one which in this example is Page2.aspx.
Maybe Master Page or ViewState could help ?
There is not a "built-in solution".
If you must do this-
If the history is small you could store it in a session.
If bigger, persist to a db.
You could also look into integrating with google analytics.
You could use Request.UrlReferrer to find out the page (or site) that took the user to the current page.
Or Page.PreviousPage which tells you the same info but has some caveats:
When you use the Transfer method or use cross-page posting to transfer
processing from one ASP.NET page to another, the originating page
contains request information that might be required for the
destination page. You can use the PreviousPage property to access that
information. If the current page is being rendered as a result of a
direct request (not a transfer or cross-post from another page), the
PreviousPage property contains null.
However, you only get the previous page. If you want the full history, you will have to enable/implement some sort of tracing in your app.
In my application I am using MSSQL reportviewer ASP.NET control inside ajax tab panel as an IFrame. My choice of putting that in Iframe is because this answer.
While loading of iframe my app sending query sting to an iframe window something like this inside URL
TabID=92&_dc=1362044299421&doc_id=456
doc_id param is my param and it is filled in main-window before loading of an Iframe.
_dc parameter I think that is an ajax automatic added parameter to query string.
What will be way to secure an Iframe from unwanted loading with some others beside my main
web Form.
I do not wont to allow users open web browser and enter url with some other "doc_id" param and to pass that to my asp.net sub-page and get unwanted data.
How I can secure my sub-page which is opening inside an Iframe that render only if is called by my WebForm.
Does this _dc parameter can be used as check-sum or key for securing query sting inside URL.
You should generate a random one per session variable in you main form server side code, pass it in the url query, and check if it is correct on your iframe page server side code.
Also you shouldn't forget to check if your user is authorized, using the same methods(like authorization cookie) as on the main page.
I've application that uses another web sites data so how can i get it because it uses some JavaScript functions to get that data and it not show in page view-source.
Check the NET tab in firebug, XHR and check the resource that is requested, and request the same resource.
Basically you have to render the webpage and ensure the javascript functions are run (evaluated). You could do this by "borrowing" their javascript files (by linking to them from your own page), but this may not work as you don't know what's in those files - they could be accessing DOM elements that you don't have in your page, or calling to other domains which may prevent them from working correctly.
The easiest way to show the same data is to just host the page inside an iframe on your own page. If you are looking to do this from a normal client application (i.e. not a web app) then you will need a browser control that you navigate to the target page. If the browser control is invisible you could then scrape values from it and show them in your app, although this is a very clumsy way to do it, and it's debatable about how ethical it is.
If you want the another web site view source use the HTTPWebRequest to get the response stream in c#.
I was wondering if it's possible to pass a session coming from PHP by simply clicking a link from the PHP site
from PHP site:
Click here
and then the ASP.NET site (www.123company.com) will get the value of id=1 and use it to validate an existing function.
Is it possible? Comments and suggestions are welcome. Thanks
My guess is no. You will have to maintain session in DB and when you navigate to the ASP.net site, it should access the same db to retrieve the session.
Quick and dirty solution:
Create an .ASPX page which accepts parameters via the QueryString.
Have your .ASPX page do some validation to check that it is your PHP script that is accessing it (i.e. not Joe Public on the internet). Then have it set each of the QueryString parameters as session variables in the normal way.
When you want your PHP page to be able to set a value in the ASP.NET session, fire off a simple HTTP request to your special ASPX 'bridging page'. It will convert the querystring variables you've passed to it via the QueryString into Session values.
Providing the user maintains the current browser window, when navigating from your PHP script to your ASP.NET site, you should fine that does just the trick...