Javascript SDK in ASP.NET C# - c#

I am building this Website in ASP.NET that needs a Log in with Facebook button (and later with Google) integrated with it to create an account.
I have looked at some great sources like
http://www.aspdotnet-suresh.com/2012/04/aspnet-integrate-facebook-login.html
and
http://facebooksdk.net/docs/web/getting-started/
[1] However, those examples never deal with Masterpages and content placeholders. So when I am trying to integrate them in the content pages, I get errors because for instance the login button called
"fb:login-button scope="email" data-size="large" data-show-faces="false" data-auto-logout-link="true" onlogin="window.location='/Main.aspx'">
Log in with Facebook < fb:login-button>"
is not accepted without the html tag
html xmlns:fb="http://www.facebook.com/2008/fbml">
which I cannot place on a content page anyways.
[2] Also, I want the user to create an account using their Facebook login. The account is really meant to be used as an instance so that a parent can sign up multiple children for a Summer Program, so all I need the application to do is associate the Facebook login with a new/existing account on my application. Any tips on how to handle this would also be greatly appreciated.
[3] Lastly, after a user logs into facebook, I would like to see them redirected to another page. However, in the code-behind file for the page, I cannot use the Facebook attributes that were written in Javascript and since the Facebook button was not an element of the toolbox, I cannot create an event handler for that. Instead, I had to write
onlogin="window.location='/Main.aspx'
within the tags of the Facebook button. This is not ideal because that means everytime I click that Facebook button, it will redirect me to Main.aspx. Meaning that if I were logged into Facebook already, and ran the Web site, I would click on "Log out" and still access the Main.aspx page...
Hope there's someone out there that has been in the same situation... or can help me!
I have been researching this for 12 hours straight now and cannot get anywhere :(

Related

How to Fix issues related to DirectLineChannel prompt choice options not displayed in chat bot window developed using V4 SDK in C#?

I am trying to create a chatbot which is having multiple waterfall dialog classes using C# and BOT SDK V4. I have created a HTML page and placed the DirectLine channel Secret Key Iframe data into it and published it to Azure successfully and opened it in the browser. The browser opens with a in-built welcome message something like: Hi bot name type Hi to continue.
If i have Choice options done through prompt options to be displayed as buttons but these are not displayed through direct line channel but works very good in Web Chat Channel?
Attached image shows the issue:
a "WebChatbotHtml_optionbtndisplayed.jpg"
b. "DirectLinechannelHtml_optionbtnnotdisplayed.jpg"
Now, in the main dialog class i have implemented the Login mechanism using the Oauth Prompt in th html page that was created above i see the login link getting displayed using which i have successfully logged in this will navigate to another waterfall dialog having prompt options with some custom choice buttons, whee if i click on a choice button the next step will be executed and respective action will be triggered.
The issue i have is normally the options are displayed for me to access but in the html that i created the all other things like login link and navigation is happening but the choice buttons are not displayed its like they are getting hidden.
or Sometimes the Choice Option buttons are not displayed at all in the Direct Channel Web chat bot
The query is how to fix the issue?
To make my query to be understood in a better way please find below set of things:
1. WaterfalldiaglogClass1:
STEP 1: Has login option/link displayed through Oauth Prompt.
STEP 2: Gets token validates it and displays login successful message and then navigates to second waterfalldialogClass
2. WaterFallddialogClass2:
STEP 1: Custom choices are displayed through Prompt options lets say 1,2,3,4
STEP 2: Capture the choice getting clicked and perform respective action
I created a HTML page where the I frame code i copied with secret code of Direct Line Channel
Published it to azure successfully with no errors or warnings
Opened the html page in a browser the chat bot opens successfully with a welcome default message like: HI i am bot,enter Hi to continue
User sends hi and logins using the login link available displayed in dialog class 1 and login successful message is displayed
Navigated successfully to second dialog successfully as i can see the prompt message given as part of prompt option and custom choices in the code
Current Issue: The option buttons 1,2,3,4 are not getting displayed it is getting hidden somehow
Need help in resolving the issue Please provide detailed step by step guide in resolving it as i am new to BOT and coding .
language: C#
Bot Framework: V4
I have tried increasing height width and other % values in the HTML page and republished it but not successful. The same thing works in web chat channel i.e. if i keep secret code inside the HTML page of webchat channel without any issues.
Issue Image attached for reference.
Expected Result: Data or choices should be shown as it is working in Webchat channel
Actual Result: Not working the choice options are not visible to choose
There are two versions of Embedded Web Chat at the moment: Gemini and Scorpio. Embedded Web Chat is currently in the process of slowly transitioning all clients from Scorpio to Gemini. It appears your embedded Web Chat is still using Scorpio which unfortunately does not support the OAuth prompt. In the near future, you will be able to manually request your client to be switched to Gemini.
In the meantime, you can add either add Web Chat v4 to your site using a CDN or wait for your client to be migrated to Gemini.
For more details regarding Embedded Web Chat, take a look at the documentation.
Hope this is somewhat helpful.

FormAuthentication with multiple login pages in webform

I'm trying to achieve FormAuthentication with multiple login pages by following this solution:
FormsAuthentication with multiple login pages
Basically the concept is to have a "middle page" that redirect you to the respective Login page of respective folder.
But I can't get this to work if I have friendly URL enabled in my application, I simply get a Redirection Loop error.
Please advise what should I do to achieve FormAuthentication with multiple login page.
P/S: I know FormAuthentication limit to have only one Login page, this is just how it being designed, a work around like the "middle page" is not a really good solution.
I been thinking to implement login myself without using FormAuthentication, but I do not have any idea how should I do it.
In one of the application I wrote previously, I store UserId in Session and use Session["LoggedIn"] = 1 to indicate the user are good to go, but I always have Session expiry issues. I know I should use Cookies but I not sure how.
if possible, just use one log-in form and use different web.config files in different directories, or one web.config with special s.
if not possible, web.config files might still help.
ex: https://support.microsoft.com/en-us/kb/316871
I had finally figure out a solution for this (perhaps a work around)
Instead of putting the Login Form inside each folder, put each Login Form in the root, then use the same concept of "middle page" and redirect them respectively.
In the Login page OnLoad function, just check if User is authenticated and have specific roles, then redirect them to the respective folder, so they wont need to signin again if they already signed in.

How can I redirect a webpage in C#

I am making a simple website in c#, I have a login system and I want to redirect a user to a new home page once they are logged in, how do I do this?
Also how do I redirect someone to a new page at the click of a button? e.g click btnMath redirects user to MathPage.aspx
Response.Redirect("url");
You can do the above
there are many method available to do so. One of those is response.redirect
Response.Redirect("MathPage.aspx")
Remember to mention path correctly inside response.redirect.
You can read this link as well.

Show default page to all (including unauthenticated) users

Here is the situation: there has been an application for years. It's old and should not be used. Therefore I created a whole new application to replace the other. Now I want to show a piece of information to the users trying to access the old one (regardless whether already authenticated or, which is more likely, not yet authenticated) and a link to the new one.
I don't want to change anything in the old one or just change as few things as possible, it should stay. So I came up with an idea: why not backing up current Default.aspx and then creating new Default.aspx telling users to try and use the new application (maybe slightly modifying web.config but how?). However, when an unauthenticated user enters ~/Default.aspx, she gets redirected to the login page.
Is it possible to allow unauthenticated users to see this default page without getting redirected to the login page just to give their credentials and then see the default page telling that there is the other application?
Are you just looking to "announce" that users should go to the "new" application (and not do an auto-redirect)?
IF SO, then wouldn't a simple html page that made this announcement be your "linker"?
The reason I'm suggesting .html (instead of an .aspx page) is that if you "don't want to change anything" in the old site, then an html page/file takes it out of the "ASP.Net pipeline" (asp.net will not process it, IIS will) - I'm guessing that the entire old application requires authentication because you mentioned the default.aspx (normally the default document of the web site/application) already requires a login (which is why it redirects).
You can set the "old" application default document to be this (new) standard "announcement" page.
Hth...

How do I redirect to a page after successful login?

I'm fairly new to web forms development, playing around with a project created using the ASP.NET Web Application template in VS 2010. After the user successfully logs in, I want the user redirected to a page I created. How do I modify my project to redirect the user after login? Any samples / tutorials / etc are greatly appreciated.
Thanks!
To simply redirect to a new page when your user has logged in, use the DestinationPageUrl property of your login control... assuming you're using the Login control that is.
If you need to do anything more advanced you can use the OnLoggedIn event handler for your Login control to perform a redirect manually, or add any code for event logging and such.
If you've rolled your own login control, and are just using things like text boxes and button controls, then in your Button_Click event, you can just use Response.Redirect("DestinationHere"); to take your users to a new page.
After you checked for login:
Response.Redirect("url");
I assume you're using ASP.NET Login control. There's a DestinationPageUrl property of that control that handles exactly that. If login was successfull user is redirected to URL provided in that property.
<asp:Login ID="Login1" runat="server" DestinationPageUrl="~/Admin/Default.aspx">
</asp:Login>
Go to Properties and Set DestinationPageUrl.
Server.Transfer( *url*) ?
(method on HttpServerUtility)
I know next to nothing about ASP.NET, but from my Java web developer daze, redirect is bad because it involves another network round trip to the browser and back when you really just want to continue processing in another page.
And Response.Redirect() really does issue a 302 response code ("try this other url instead") back to the browser. yuck. XP
Server.Transfer() looks like the java version of Response.Forward()
For Sharepoint farm solution development
Page.Response.Redirect("url");
The issue with Response.Redirect() is the 302. In some browsers (eg Chrome) this causes the new session cookie to be immediately invalidated.
In other words, using that method to redirect causes the user to no longer be logged in, so you did not accomplish your purpose!.

Categories

Resources