How can i change session when open url in another tab in asp.net - asp.net

I am developing one web application in asp.net. I am opening my all pages on pop up window. I want to expire my session or change the session value when someone copy the url and paste it into another tab. How can i implement it ?
Please help me out.

A simple way would be to check Request.UrlReferrer. The Referrer would be empty if the user copy pastes a URL.
A couple of points you should consider before using this:
Provide exceptions for any pages that can be directly entered by
the user. For e.g. the login page or a page that can be bookmarked
I believe a pop can be opened from Javascript, without a referrer. Make sure your existing code is not using this method to open a pop up.
For a generic way to determine if the user has opened a new tab, see here

I have solved this problem by using this
string referer = Request.ServerVariables["HTTP_REFERER"];
if (string.IsNullOrEmpty(referer))
{
Response.Redirect("../Index.htm");
}

Related

How to open page in new tab/window?

I need to perform something like app.showPage(app.pages.%PAGENAME%)but open the page in new tab.
Is it even possible in appmaker?
I am not opening an external link, I need to open the page of the app in a new tab.
Client property app.buildUrl().__gwt_instance.a; contains app's URL.
Not sure if a good practice, however it fulfilled my needs

Redirect to a specific page using session variable

We are working a big project here in ASP.NET\VB.NET
The web site is a tool to manage projects.
We use session variables to naviguate between ProjectID selected by the user in some search page. So say the user selects "Project X" in the result page of whatever search on the website. We get the ProjectID from the database and pass it to a session variable to load up the Project Info page.
Now the good stuff, we produce multiple reports in Excel linked with the webpage. We'd like to add a link in the Excel page to redirect the user into the selected project info page. Since we're using session variable and it's server side, we have a hard time figuring out how to do this. Is there anyway to pass the info in the URL to affect the session variable ?
Offhand, when you generate the page your on the server, generate the url and put the parameter into the querystring. Then when you load the linked page, you check the query string first, if a value exists use it over the session...

Running Canvas app in a Tab

This is my first Facebook app and I'm on quite a tight deadline so forgive me if any of this is a dumb question.
I've set up a Canvas app, I've got it to authenticate by passing the parameters to the facebook URL:
https://www.facebook.com/dialog/oauth?client_id=1234&redirect_uri=MY_APP_URI
I can then get the user_id and name of the user, which for this particular app is all I need. It runs fine in the Canvas page.
Problem is I can't get it to run in a tab, it always redirects to the Canvas, which is not what I want - I need it to run within the context of my client's Facebook page. I've been trying to find examples of setting it up but everything seems to be out of date compared to what I'm seeing in the App settings.
My settings at the moment are:
App on Facebook
Canvas URL: http://localhost/facebook/
Canvas Page: http://apps.facebook.com/MYAPP
Page Tab
Page Tab Name: My test app
Page Tab URL: http://localhost/facebook/
I presume I'm missing something obvious, so if someone can advise I'd be grateful. For what it's worth I'm using .Net webforms and have the C# SDK installed, but don't think I'll need to really use it for this example.
EDITED TO ADD
I'm sure its to do with the authorization - I've followed the guide here developers.facebook.com/docs/appsonfacebook/tutorial on how to redirect the page back with the authorization payload, but obviously doing that has kicked it out of the tab and into the main Canvas again. I need to to stay where it is, if such a thing is possible.
localhost points from your local machine to itself. Facebook does not know what localhost relates to and cannot load the app. You need to make your app accessible from outside of your machine.
It was the fact that I was still redirecting the url, when you run in a tab you don't need to redirect to another url to get the user data, it's just there waiting.

ASP.NET - Send Information to Website

I have an asp.net webpage that only contains a textbox and a button. The user submits their email address using this webpage.
What I am trying to do now is take the information submitted by the user and go to another website. Where my "website/program" gives the different website the entered email address, and clicks the submit button.
If I where to physically go to the different website, there would be a textbox to enter the email. But since I am accessing the website from my page "behind the scenes" I cant manually enter their email address...
Is it possible to do this, if so how? Also, my code behind is in VB.
Thanks!
Well it can be done, but the simpllicity of it depends on what this other webpage is. Will this webpage always be the same or can it change?
If it a dynamic website that will frequently change, then you will need to basically parse the html and emulate how the email address gets posted to the webpage. Look for the tag in the html and see what page it posts to.
What you want to do is use HttpWebRequest. This class can send information to another web page. Here is a tutorial on how to do what you are asking: http://www.jigar.net/howdoi/viewhtmlcontent106.aspx
And here is the MSDN documentation on it: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(VS.71).aspx
Keep in mind that my solution will work if the web site is using POST or GET, but some sites use Javascript. To do this, it will require you to build a javascript interpreter.

Even after loging out I can go back to the home page using BACK button!

I am using ASP.net with C#.After I logout its possible to go back to pages using back button.I could fix the prob for the login.I have prob with the logout.I am using the inbuilt login page provided by the asp editor.Should I use sessions?
please help.
This is a caching issue. Browser will be loading the page from cache. You can disable caching of the Home page, and check for user session in that page. By this you can avoid the problem.
See HttpCacheability Enumeration
On all pages in your site, you need to check if the user is still logged in and if not, log them out.
You also need to make sure that the pages are not cached on the browser on anywhere else.
After using the back button, try doing some process that needs login privilages. I think you are logged out already but your browser is displaying your page from the cache.
As #Rahul has identified this is a cacheability issue. Basically what is happening is when the user visits the page the browser is caching it. So regardless if the user is logged in/out, when the user selects the back button, the page being retrieved from the cache not the server.
If you want to ensure the page is always retrieved from the server (which will effectively resolve your issue) you need to set Cacheability to NoCache. See Setting the Cacheability of a Page.
See Login on the Web. The same principles apply.
I used history.forward() in the header of the web page, which I didn't want to be displayed.
It is working.

Resources