Magic with URL in asp.net - 3.5 - c#

This is my dilema:
My web site done in asp.net 3.5. I have buttons which if the user clicks should show images. The images are located at a third party and accessible via web url. So my app has to login to this third party app and they will return a url to me which i should then do a response.redirect in my website and show the user images
Think of it as have your own web page. you want to displlay images from yahoo and you need to log on to yahoo and all you have is a web address and know that it takes in username/password as either form elements or you could do yahoo.com?username=blah&pwd=doe
This would in normal sense take you to your yahoo home page and the login call also returns you a random file path which you use in your asp.net app and perform magic so that your web page is now redirected to yahoo.com/username/randomfilepath, which is basically a thumbnail page of your images.
i have tried doing this webrequest and then performing a response.redirect once i got the response back but that was a show stopper.

You might want to think about doing this inside of an IFrame. I did some facebook work which required the user to login to their facebook account. Then facebook returned to a my page at a url i specified.
What I did was create an IFrame then using the JQuery Dialog plugin showed the iframe, had that iframe postback to a FinishedLoggingIn.aspx page, then from that page I called window.top.someJavascriptToDisplayImages(someJsonWithImages);

Related

How to redirect to callback url using POST

I am a newbie to ASP.NET NVC and I'm currently (self) learning how to consume Web APIs. I want to integrate an OAuth Web API into my ASP.NET MVC application to have the following flow.
User clicks Login Button
redirect to API-login website
User logs in
User accepts T&C
The redirected page URL has the access token
Access token is retrieved by the main MVC app
Using HTTP Post, the necessary data is displayed on the page.
Currently I am able to redirect to the login website using the Redirect(Uri url) method and carry out steps 1-4. However, I am stuck at step 5 where the T&C page redirects to a page with the access token as part of the URL, which produces a server error (because I haven't implemented the https://localhost:5241/redirect in my application yet)
The URL with the token is in the form https://localhost:5241/redirect?token="abcde..."
Please advise me as to how I should implement the /redirect portion to redirect to my main page (in step 1), and how I can parse the token from the redirected URL.
My current approach is to create a redirect controller which redirects to the main page (home controller) and creates the POST request in step 7.
Any help/advice would be appreciated.
Thank you.

Refreshing current browser within iframe

I created a Registration Page in MVC 7 for a company but they only implemented the page as an iframe so once the user is successfully registered I redirect my created page to their home page but because this was implemented as an iframe, only the iframe loads the homepage so it looks like the website is inside itself. My page is also hosted on a different service as the website they implemented the iframe on. I do not have access to the current website's back-end so I was wondering if there was a way to refresh the entire website and not just the iframe. If anybody has some advise on how to do this using any method allowed on MVC I would appreciate that.

Hide URL in ASP.NET application

I am developing an ASP.NET application. But i would like to hide the URL so user don't know on which page he or she standing. Is their any solution?
Use Server.Transfer . It doesn't change the URL.
Server.Transfer happens without the browser knowing anything, the browser request a page, but the server returns the content of another.
Server.Transfer() should be used when:
we don't need to show the real URL where we redirected the request
in the users Web Browser
we want to transfer current page request to another .aspx page on the
same server
we want to preserve server resources and avoid the unnecessary
roundtrips to the server
we want to preserve Query String and Form Variables (optionally)
There is no solution unless you can force the user to browse only from a restricted environment in which you can control what software is installed or run. Even if you force the user to use a specific browser, they could use a tool like Fiddler to see what URLs they are going to.

How to screen scrape a site with dialog based authentication?

I want to use Jsoup to screen scrape contents of a website. But I have to login first into the site. On browsing to the main page I get a dialog for username and password. Since it is not a form, I am getting the "not authorized" page as the response in in Jsoup. I tried to look for the url using firebug but I guess the dialog is appearing before the other page components are loaded. Hence I don't know what are the parameters I need to pass for the username and password fields nor do I get to know the service where I need to post.
This is a C# based website. I have seen this authentication mechanism in several Sharepoint sites.
How should I go ahead with this kind of login mechanism ?
Sounds like the page is using basic authentication. This happens before any HTML is sent to the client, so that's why you don't see it in firebug.
You need to send the username and password in a http-header, and here's a link that shows you how to do that:
Jsoup connection with basic access authentication

c# Auto login to sprint

I have a project where I am trying to login to sprint and then do some screen scraping to get data about the different lines that the company controls. I have tried passing the cookies that are provided by the initial website call in the initial HttpWebRequest form post, but I do not get any cookies back that will denote user or session or anything. In fact, if I then try to use the WebClient class to get the landing page, the response url that I get back is the login page.
I think it is due to the fact that when you login, you get redirected to a page that does some processing and then redirects you to the landing page. I am passing in correct credentials and don't know where it is failing. Can anyone help me so that I do not need to use Watin or any other browser control to scrape that data as that will be too slow.
Use Selenium.
It is normally for website testing, but you easily use it for your situation.
It allows you to launch a browser and programmatically control mouse clicks and keyboard presses to do exactly what you need.
You also run xpath on the HTML to read data, or even run custom javascript on pages if you need to get more complicated.

Categories