Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPF empty POST data when using custom popup #1267

Closed
coldicelion opened this issue Sep 14, 2015 · 21 comments

Comments

@coldicelion
Copy link

commented Sep 14, 2015

hello! i try to popup a new window(

) in Cefsharp, but i found that my POST data was lost, no POST data in it. but this problem is only in WPF Example. i try to the same way in Winform Example, its works fine.

@amaitland

This comment has been minimized.

Copy link
Member

commented Sep 14, 2015

What version are you using? Which branch did you checkout?

@jankurianski

This comment has been minimized.

Copy link
Member

commented Sep 14, 2015

Can you also provide a code sample to make it easier for other people to reproduce the problem?

@coldicelion

This comment has been minimized.

Copy link
Author

commented Sep 14, 2015

i used the 3.2357.1287,but i think All CefSharp's WPF versions has this same problem, when i open a web page, there is a form in it, i input some information and submit, and in my ASP programs, i use the code “Request.Form” to get the information, if i set the form's target like “ target=_blank”, and then i can't recieve any POST data, i think may be the problem is OnBeforePopup can not pass the POST data?

When i set tartget="_blank", Cefsharp will popup a new window the show the page, but the page only output POST DATA:, and i also use the chrome to open the page ,it works fine, please help me ,than you very much.

my index.asp's code:
[html]
<form action="destination.asp" method="post" target="_blank">
User:<input type="text" name="user" value="lion" />
<br>
Pass:<input type="text" name="pass" value="123" />
<br>
<input type="submit" value="Test POST Data" />
</form>
[/html]

my destination.asp's code:
[html]
<body>
<%
Response.Write("POST DATA:"+Request.Form)
%>
</body>
[/html]

in Cefshap WPF Example:
qq 20150914235210

in Google Chrome:

qq 20150914235747

@amaitland

This comment has been minimized.

Copy link
Member

commented Sep 14, 2015

i used the 3.2357.1287,but i think All CefSharp's WPF versions

That's a CEF version number. The latest official CefSharp release can be found at https://github.com/cefsharp/CefSharp/tree/cefsharp/41

Can you form the MinimalExample to demo your problem? The MinimalExample uses the release Nuget packages. The cefsharp/43 and master branches have experimental code for popups that's not ready for production use yet.

https://github.com/cefsharp/CefSharp.MinimalExample

@coldicelion

This comment has been minimized.

Copy link
Author

commented Sep 16, 2015

thanks again, i uesed the version 43 (branch cefsharp/43 ) , 3.2357.1287, after 2 days, i did what ever i can do,but still has this problem, i'm not sure i can make a demo to show this problem, because i need a server to put my ASP Programs on it. but i'm very sorry, i don't have a free server. thanks a lot.

@jankurianski

This comment has been minimized.

Copy link
Member

commented Sep 16, 2015

Does the problem occur using the normal CEF test application cefclient.exe? Here is an explanation of where to download it from:
https://github.com/cefsharp/CefSharp/blob/master/CONTRIBUTING.md#cefsharp-vs-cef

@amaitland

This comment has been minimized.

Copy link
Member

commented Sep 16, 2015

Comment out the following line
https://github.com/cefsharp/CefSharp/blob/cefsharp/43/CefSharp.Wpf.Example/Views/BrowserTabView.xaml.cs#L25

If it works then, it's a problem with the custom popup handling (for which there are a few known issues).

amaitland added a commit that referenced this issue Sep 16, 2015
@amaitland

This comment has been minimized.

Copy link
Member

commented Sep 16, 2015

As expected the post data isn't work when using the custom popup implementation.

Example to demo post data was added to master
3fac742

Comment out the custom LifeSpanHandler reference and everything works fine.

@amaitland amaitland added the wpf label Sep 16, 2015

@amaitland amaitland changed the title CefSharp.Wpf.Example can not pass a POST data when popup a new window WPF empty POST data when using custom popup Sep 16, 2015

@amaitland

This comment has been minimized.

Copy link
Member

commented Sep 16, 2015

Have temporarily removed the custom LifeSpanHandler implementation from the Wpf.Example project as it's not ready for production use yet.

@coldicelion

This comment has been minimized.

Copy link
Author

commented Sep 16, 2015

thank you very much! you guys are awesome! i think may be the custom popup handling has a little problem. i will find the other way to do it.

@amaitland

This comment has been minimized.

Copy link
Member

commented Sep 16, 2015

i think may be the custom popup handling has a little problem

It has quite a few problems to be honest. It's a new feature and one that I don't believe has been very well tested in the CEF context, so will likely need some upstream fixes.

@amaitland amaitland added the upstream label Sep 16, 2015

@DonSleza4e

This comment has been minimized.

Copy link

commented Jul 13, 2016

I also hit that problem (wpf, v49.0.1)

I have a custom LifespanHandler.cs
I have a url (I have no access to modify it) with
<form method="post" action="bank.php" target="_blank">....</form>

This test code working fine - new page opens in ugly popup

    bool ILifeSpanHandler.OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
    {
        newBrowser = null;
        return false;
    }

But, I would like to open new urls in new tabs in my application (so I have multitabbed interface)
My current code worked fine until now (when I use it on page with
<form method="post" action="bank.php" target="_blank">....</form>

    bool ILifeSpanHandler.OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
    {
        //We would like to create a new tab
        ChromiumWebBrowser chromiumBrowser = null;

        //main form is in different thread, so accessing via dispatcher
        Application.Current.Dispatcher.Invoke(new Action(() =>
        {
            //create new tab
            -----.CreateNewTab(targetUrl);

            //assign new browser (however it's null here, not yet initialized)
            chromiumBrowser = ------.WebBrowser;
        }));

        newBrowser = chromiumBrowser;

        return true;    //do not open this link in child window
    }

As current workaround I planning to add temp solution - check for specific url and show content in default ugly popup... I know it not good solution, but looks like I have no choice for now. Or do you have some suggestions for me? Thanks

@amaitland

This comment has been minimized.

Copy link
Member

commented Jul 13, 2016

@DonSleza4e Is this issue relevant to your problem? I don't see any reference to post data???

Your responsible for creating a new ChromiumWebBrowser instance and assigning it to newBrowser. As a whole the feature is still experimental and not recommended.

@DonSleza4e

This comment has been minimized.

Copy link

commented Jul 13, 2016

Well, I understood it as relevant one. Sorry if it's not

I created simple php page for live testing
it's available at http://mibs.info/test.php for testing purposes
Problem is occurs when application works with forms with target="_blank"

<html>
<body>
    <form method='post' action='test.php' target="_blank">
        <input name="field_a" value='value 1'/>
        <input name="field_b" value='value 2'/>
        <input type='submit' value='submit'/>
    </form>
    <br/><br/>
    <?
        echo "post data #1: " . $_POST['field_a'];
        echo "<br/>";
        echo "post data #2: " . $_POST['field_b'];
    ?>
</body>
</html>

If I open it in Chrome and press "submit" button, its creating new tab and shows post data. Its good.
When I open it at CefSharp with

      bool ILifeSpanHandler.OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
        {
            newBrowser = null;
            return false;
        }

System shows default popup with post data. It's also good

When I open it at CefSharp with custom OnBeforePopup (I provided it before) - it's creates new tab with test.php and no post data. So here is my problem

Your responsible for creating a new ChromiumWebBrowser instance and assigning it to newBrowser. As a whole the feature is still experimental and not recommended.

Well, it worked each time before. Until this one problem url... So problem is quite specifical. For pages with <form method='post' action='test.php' target="_blank">
If this feature experimental, how should I correctly open urls from prime browser in new tabs in my application instead of popups?

@amaitland

This comment has been minimized.

Copy link
Member

commented Jul 14, 2016

Well, I understood it as relevant one. Sorry if it's not

From your code sample it wasn't clear that it was actually the same problem.

If this feature experimental, how should I correctly open urls from prime browser in new tabs in my application instead of popups?

The bug would need to be fixed in CEF to allow this. CefSharp is just a wrapper.

@DonSleza4e

This comment has been minimized.

Copy link

commented Jul 14, 2016

Does this bug reported to CEF team? I'm not familiar with C, and have no idea where to look on

@amaitland

This comment has been minimized.

Copy link
Member

commented Jul 14, 2016

Does this bug reported to CEF team?

You can search the CEF project issue tracker https://bitbucket.org/chromiumembedded/cef

@DonSleza4e

This comment has been minimized.

Copy link

commented Jul 15, 2016

Thanks, I reported it here https://bitbucket.org/chromiumembedded/cef/issues/1949/
Let's hope they'll fix it

@amaitland

This comment has been minimized.

Copy link
Member

commented Jul 15, 2016

Let's hope they'll fix it

I've seen similar issues reported take 6-24mths to fix, so I wouldn't get my hopes up. Quickest way would be to solve it yourself.

@connie61

This comment has been minimized.

Copy link

commented Nov 12, 2018

@ DonSleza4e
Is this problem solved?
I also encountered the same problem and could not be solved.

@amaitland

This comment has been minimized.

Copy link
Member

commented Jul 23, 2019

Quick test and this appears to be resolved with the new Network Service implementation added to CEF in version 75. Anyone still experiencing issues should follow up on https://bitbucket.org/chromiumembedded/cef/issues/1949/

@amaitland amaitland closed this Jul 23, 2019

@AmesianX AmesianX referenced this issue Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.