How to website logout click using webbrowser1 - vb.net

I am using VB.NET, i want click logout link using webbrowser or another component.
Thanks for help.
<a class="end" href="#" onclick="document.logoutForm.submit(); return false;">Logout</a>

You do not need even "onclick" event. You do not need to post because logout.aspx page is only meant to kill the current user session so GET request (which is default) is enough.
<a class="end" href="logout.aspx">Logout</a>
Inside, logout.aspx codebehind file you can kill the current session.
Inside logout.aspx page_load event:
Session.Clear()
Session.Abandon()

Related

webview2 vb.net accept cookies button press

I previously used the old ie based control
But have a new project getting data from a web page
Its a login page so im hoping to use the control to grab login then get the relevant data then log out.
However when loading the page in the control the html elements dont apear to have an id.
The first problem I have is the accept cookie button which in dev tools shows as
<a class="acceptAllButtonLower" tabindex="0" role="button" aria-hidden="false" style="">Accept All</a>
Next button to press is
<button class="sign-in-btn" ng-click="vm.signIn('\\',true)">
SIGN IN
</button>
i have tried
WebView21.CoreWebView2.ExecuteScriptAsync("document.getElementsByClassName('acceptAllButtonLower')[0].click();")
and
WebView21.ExecuteScriptAsync("document.getElementsByName('acceptAllButtonLower')[0].click();")
with no luck.
Im not even sure the click is being passed etc.
Can someone kindly point me in a better direction.
Ta
Have tried the above with no success

_ServerClick event and Response.Redirect: wrong redirection

Perhaps this question is a bit too general, but I'll try to narrow it down by explaining my scenario.
I have a login page, with an html input button:
<input runat="server" id="btnLogin" type="submit" value="Login"></input>
The button triggers the btnLogin_ServerClick event which runs a validation routine.
If the user is validated the following happens:
HttpContext.Current.Response.Redirect("~/myPage.aspx")
This is all good in development environment.
However, after I deployed my application, the validated user would still be redirected to the localhost URL, instead of the application URL corresponding to the root directory.
After lots of trials and errors, I've fixed the issue by changing the button to a webcontrol namespace button:
<asp:Button runat="server" ID="btnLogin" Text="Login"/>
This triggers a Click event in the code behind.
The routine is exactly the same as in the development environment, but the user is now redirected to the appropriate URL.
So, could anyone explain why the ServerClick event was making Response.Redirect "behave" differently?

How do I modify Login page submit to call my custom function before the normal flow in Sharepoint 2010

I want to modify the login page of Sharepoint 2010 to change the normal flow during page submit. I want my custom function to be called, Validate it and go to actual submition of the page based on the validation result.
I have tried calling my custom function using onclientclick in the "asp: Button" tag. The custom function gets invoked, but I am unable to make the flow complete by sumbitting the login page. Once the custom function gets executed, the whole execution is stopped.
Please help me in solving it.
Thanks in advance.
I solved it my self. As mentioned I had added an extra submit button. SO when a user clicks the 'Sign In' button the custom function is called. On its success I made the original asp:button to click.

How to make submit form which goes to the same page in Joomla

I am making form with submit button in Joomla custom HTML and I would like to stay on the same page after I click on the submit button.
Is that possible? Thanks in advance.
Just leave the form action attribute out. This will post back to the same page. Have a look at this question and answer: Is it a good practice to use an empty URL for a HTML form's action attribute? (action="")
If "stay on the page" means that the page will not reload, or anoter page will be loaded, yes, thats quite possible. I think the best way of doing this is replacing the <input type=submit> with a <button>, which calls a javascript function that evaluates the form, submits the data via ajax, and notifies the user that the form was successfully submitted.

Disable Page Cache to force page load with browser back button

I have an asp.net website that is using update panels on the page that i cant get to reload from the server. I have this for the disable page cache on the master page.
Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
Response.Cache.SetValidUntilExpires(False)
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetNoStore()
When I click the browser back button to go back to the page it says the page has expired. The other pages on my web site work and call the page load, the only solution i found but cant use is to wrp the whole page in an update panel, but i can't do this because i have a report viewer on the page that does not work with ajax. If anyone can help i would deeply appreciate it.
This is not a browser cache problem; it's a postback one. You have to implement the Post/Redirect/Get pattern in order to avoid the "do you want to submit again? / page expired" message.
http://en.wikipedia.org/wiki/Post/Redirect/Get
The classic example for this thing is when a web page has a save button that insert something in a Database. The "Save" button is clicked -> a postback occurs -> code insert a row in a table -> user refres the page (F5) -> postback occurs again -> code insert the same row again.
To avoid the double insert in the previous example you need to redirect when the "save" button is pressed and only then, execute the insert.
Just add this in your view file in header part:
<head>
<script language="JavaScript">
<!--
javascript:window.history.forward(1);
//-->
</script>
</head>
Inside body tag add this:
<body onUnload="OperaReload()">
<input type="hidden" id="refreshed" value="no">
To reload the page with JavaScript use the following:
window.location.replace(window.location.pathname);