WPF Browser Control Navigation - c#

I need to have a Embedded browser in my WPF application to show web related content. I have decided to go for WPF Browser control, and my fundamental requirement is I should be able to login to home page directly, without asking the user to sign in again in the web application (Single Sign on). I am able to navigate to the page through the WebBrowser.Navigate() method, but I am not able to automatically log in. I have tried WebBrowser.Navigate(url, null, null, authHdr); but of no use. It is directing me to login to the web site. I have also checked something that is possible through Awesomium but didn't find any solution as of now. Can anyone help me regarding this?

Related

WPF Process.Start(url) how to know current URL or when window is closed

I have a WPF application that redirects to a payment system and then starts pooling a database to see if the transaction reference was posted back via a different channel.
I had a chat with one of my programmer friends and he said that there was no need for pooling and I could have simply tracked Url to which payment system redirects after successful payment and react accordingly.
Code to open window and redirect agent to payments system is as follows:
var process = Process.Start(new ProcessStartInfo(url));
Is there a way to get the Url of the Browser Window?
I would recommend to use a web browser control inside your application. There are very good ones and a built-in version (called WebBrowser). Process.Start is a problem since you never know which browser (and version) is loaded. You have support a lot of different ways to get the URL.
The benefit of using a web browser control in your application is that you have absolute control of the web browser, you can handle events like loading of pages, which enables you to perform checks on the URL. I use this myself to do OAuth authentication on a client and get the token back from the URL and parse the token out of it.

windows form application to web page application

I have this requirement for my project. Already there is an existing windows form application,
Which sends email when a button is clicked. There's a lot of code behind the application.
It validates the field serial number which is a text box by connecting to database.
The validation error pops up as another windows form.
It generates a report form after sending an email. There's a configuration button which is accessible only to particular users which opens configuration form which has details of email settings.
Now All this is developed using windows forms. My new requirement is i need to develop
the same in a ASP.NET web page having similar functionality.
I tried using click once deployment, but that's not they needed. they want it as a webpage.
Is there any tool or way i can show the application in ASP.NET web page?
Do i need to start the coding from scratch?
Thanks in advance
As to what Rex said, you are going to have to start from scratch. The coding behind it is different. Validation and functions work differently in asp.net than they do in .net.
You will have to start from scratch for reasons already mentioned. If this is your first ASP.net application here are a few tips for what you want to do:
1- For validation and transfer to the email report to work in a similar way you can use Response.Redirect or Server.Transfer or JavaScript. All of those methods have pros and cons, see Server.Transfer Vs. Response.Redirect for an example of the first two. For javascript you'll need to write a javascript function in the .aspx file or inject javascript in the page with response.write.
2- If you validate with JavaScript you also need to validate server side to make sure someone doesn't try to pass bad values to you. JavaScript can be disabled and users can call your report page and configuration page directly, while with windows forms you control that flow you don't on webpages.
3- You'll probably have to use CSS to style elements in your email configuration form and in your initial form. Positioning, docking, anchoring and so on is completely different in webpage and done with CSS. Have fun learning the CSS boxing model, what absolute positioning is, and what clear and float do ;)
4- The most important thing is that the Web is stateless. You can't use private members to keep information between page reload on the web. When you pass a value between 2 pages the first one doesn't exist anymore so you can't just do Class.somemembervariable as usual. Check out what viewstate, sessionstate and querystring are. When your page reload, without these, everything is loss. Clicking a server-side button cause the page to reload, which you need to handle (it's called postback). This also implies that when you serve the report page you will have to pass some Id for the email and check the user, so when you call the 2nd page you need to pass to it some id so it can work. I spent more time on this one because it's the most important difference between asp.net and windows form.
5- For restricting access to your email settings page you will probably need to use windows authentification if this is an Intranet site or Forms authentification if this is an Internet site. Check Starting ASP.NET Forms Authentication for some basic overview.
6- ASP.Net has a codebehind file where you write the actual code, and an .aspx page where you put the html tags, javascript, styles, and data binding with <%= %> tags.
7- You will probably have to work with IIS as well to make your website work unless you work at a very formal place where specific peoples take care of that. At the very basic you'll have to create an application pool, make it compatible with 32/64 bits and set up authentification in IIS.

ASP.NET Authenticate Request Without Redirect

I'm having trouble figuring out how to do something that I imagine is very common in an ASP.NET Web Forms application.
It's a pretty standard app with the usual inputs (dropdowns, text editors, etc), and we want to make sure that when the user tries an action (like clicking the "save" button after their edits), the data they've entered is not lost if they are logged out without their knowledge (session expired, cache got cleared, etc).
We use Telerik's ASP.NET Web Forms controls, and our first solution was to hijack the OnRequestStart event of the RadAjaxManager, along with several built-in Telerik javascript events (overwrote the Telerik events for button click, drop-down opening, etc) in order to make sure that our authentication check would be hit on just about every action throughout the app. From those functions we then called a synchronous Ajax request to a web method that returns whether the user is currently authenticated. If they aren't, we stop the current request in javascript and pop up a login window so the current page is not redirected.
We did this without the foresight that there would be potentially thousands of requests to this web service, which essentially crashed the app in spectacular fashion. I've been exploring other options, like using the Application_AuthenticateRequest event in the Global.asax, but no luck so far.
The web service solution is kind of ideal in theory, if only it didn't doom the app to a fiery, unresponsive death...! Any thoughts that could point me in the right direction? Thanks in advance for any help.

facebook c# sdk page tab application

First of all, sorry for my newbie question...
I am google-ing for something like that for days, but still no luck.
I can't find any examples for using the Facebook C# SDK
with Facebook Page Tab applications.
Unfortunately most examples are for Facebook Canvas applications
and I can't make them work with a Page Tab application.
I really need to see a working example of the following:
Get whether the User Liked my page, or not.
If the User Liked my page, show an "authorize" link/button.
On clicking the "authorize" link/button, ask for User's permission to:
access his info, post to his wall, etc.
(using facebook's usual dialogs for that)
After the User accepts, redirect him to the "member's only" page.
(...inside the tab application frame. not a canvas-type frame)
Whenever an "authorized" User comes back to my tab app,
he should be automaticaly redirected to the same "member's only" page.
(I suppose if I have an example for the previous steps,
I won't have a problem figuring this out)
Building app for canvas is the same as making it for Page tab. The only difference is the so called "fangate" (liker/non-likers).
This can be used out of the box only on page tabs and the only thing you need is to decode the signed request passed by facebook.
There is good explanation for doing this with C# here:
Decode Signed Request Without Authentication

Close silverlight applications and redirect to parent applications

My company is developing a Silverlight application which we then give to our clients who integrate it with their product. You can log into the application by going through a form or using a URI where you pass some needed data. If you provide false data (i.e. you can not be authenticated) you get a message and the applications closes. Then the user just has a blank (white) screen in front of him. We don't want that to be the case any more. Instead we would like to redirect to the calling page (where the user clicked the link to start the app).
So if for example user A has his application open on http://hisdomain.com/work and clicks on a link that redirects him to our Silverlight app where the authentication fails we would like to show him a message (this is happening at the momment) and then redirect him back to http://hisdomain.com/work.
Any ideas how to do this?
I am still in R&D about this so I have not much of an idea about it. The only thing that came to my mind was to pass in the calling URL along with the rest of the data.
Thanks.
If you can pass the starting URL into the Silverlight app with the startup params, you can redirect back with this:
System.Windows.HtmlPage.Window.Navigate(new Uri("YourStartupUrl.aspx", UriKind.Relative));

Categories

Resources