Home

Opening Edge (Chromium) using 'System.Diagnostics.Process' and pass request header to target url

%3CLINGO-SUB%20id%3D%22lingo-sub-892843%22%20slang%3D%22en-US%22%3EOpening%20Edge%20(Chromium)%20using%20'System.Diagnostics.Process'%20and%20pass%20request%20header%20to%20target%20url%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-892843%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3CBR%20%2F%3E%3CBR%20%2F%3EWe%20need%20to%20launch%20Edge%20(Chromium)%20using%20'System.Diagnostics.Process'%20with%20header%20to%20target%20URL%20request.%3CBR%20%2F%3EMy%20code%20is%20-%26nbsp%3B%20Process.Start(%22microsoft-edge%3A%22%20%2B%20%3CURL%3E)%3B%3CBR%20%2F%3EWhich%20work%20and%20open%20the%20Edge%20with%20url%20argument.%3CBR%20%2F%3E%3CBR%20%2F%3EHow%20can%20I%20pass%20a%20request%20header%20to%20the%20url.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FURL%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-894263%22%20slang%3D%22en-US%22%3ERe%3A%20Opening%20Edge%20(Chromium)%20using%20'System.Diagnostics.Process'%20and%20pass%20request%20header%20to%20target%20url%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-894263%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F419953%22%20target%3D%22_blank%22%3E%40Kamal1315%3C%2FA%3E%26nbsp%3BIn%20general%2C%20you%20should%20avoid%20launching%20a%20user's%20browser%20using%20a%20protocol%20handler%20wrapper%20(like%20%22microsoft-edge%3A%22)%20and%20should%20instead%20just%20pass%20the%20URL%20(e.g.%20%22%3CA%20href%3D%22https%3A%2F%2Fwww.foo%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.foo%2F%3C%2FA%3E%22).%20This%20will%20ensure%20that%20the%20user's%20default%20browser%20opens%20and%20handles%20the%20link.%20The%20default%20browser%20is%20more%20likely%20to%20work%20correctly%20vs%20a%20browser%20that%20is%20not%20their%20default%20(which%20might%20not%20have%20correct%20proxy%20settings%2C%20extensions%2C%20VPN%2C%20account%20info%2C%20etc).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20the%20other%20part%20of%20your%20question%2C%20no%2C%20there's%20no%20standard%20for%20opening%20a%20browser%20and%20passing%20headers%20or%20POST%20body%20information%20as%20a%20part%20of%20the%20initial%20request.%20There%20are%20ways%20to%20do%20this%20in%20certain%20browsers%20(e.g.%20Internet%20Explorer%20using%20COM%20invocation)%20but%20no%20reliable%20cross-browser%20standard.%20Instead%2C%20there%20are%20two%20possible%20routes%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20Write%20a%20local%20HTML%20file%20that%20contains%20a%20form%20that%20automatically%20submits%20the%20desired%20data%20to%20the%20target%20server.%20This%20will%20allow%20sending%20of%20POST%20requests%2C%20etc.%3CBR%20%2F%3E2.%20Write%20a%20remote%20HTML%20file%20(e.g.%20on%20your%20server)%20that%20contains%20a%20form%20that%20automatically%20submits%20the%20desired%20data%20to%20the%20target%20server.%20This%20will%20allow%20sending%20of%20POST%20requests%2C%20etc.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENeither%20of%20these%20approaches%20is%20likely%20to%20allow%20you%20to%20pass%20a%26nbsp%3B%3CEM%3Eheader%26nbsp%3B%3C%2FEM%3Eto%20the%20target%2C%20insofar%20as%20there's%20no%20standard%20way%20in%20the%20web%20platform%20to%20%22Navigate%20with%20header%22.%20That%20restriction%20exists%20mostly%20for%20security%20reasons.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20header%20do%20you%20need%20to%20pass%2C%20to%20what%20service%20or%20server%3F%20Do%20you%20control%20the%20service%2Fserver%3F%20Must%20the%20data%20be%20in%20a%20header%20vs.%20a%20POST%20body%20or%20Query%20Parameter%20on%20the%20URL%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-896233%22%20slang%3D%22en-US%22%3ERe%3A%20Opening%20Edge%20(Chromium)%20using%20'System.Diagnostics.Process'%20and%20pass%20request%20header%20to%20target%20url%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-896233%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F317619%22%20target%3D%22_blank%22%3E%40ericlaw%3C%2FA%3EThanks%20Eric%20for%20reply.%3CBR%20%2F%3EPlease%20see%20my%20comments%20for%20your%20query%20-%26nbsp%3B%3CBR%20%2F%3E%5BWhat%20header%20do%20you%20need%20to%20pass%2C%20to%20what%20service%20or%20server%3F%20Do%20you%20control%20the%20service%2Fserver%3F%20Must%20the%20data%20be%20in%20a%20header%20vs.%20a%20POST%20body%20or%20Query%20Parameter%20on%20the%20URL%3F%5D%26nbsp%3B%3CBR%20%2F%3E%3D%26gt%3B%20We%20need%20to%20pass%20authentication%20header%20to%20our%20own%20server's%20hosted%20web%20application.%3CBR%20%2F%3EAuthentication%20details%20are%20normally%20sent%20via%20header%20only%2C%20so%20no%20post%20body%20or%20query%20string%20parameter.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-897079%22%20slang%3D%22en-US%22%3ERe%3A%20Opening%20Edge%20(Chromium)%20using%20'System.Diagnostics.Process'%20and%20pass%20request%20header%20to%20target%20url%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-897079%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F419953%22%20target%3D%22_blank%22%3E%40Kamal1315%3C%2FA%3E%26nbsp%3BYeah%2C%20unfortunately%20this%20(%22Add%20a%20header%20to%20a%20navigation%20request%22)%20isn't%20a%20capability%20present%20in%20the%20web%20platform.%20You%20could%20write%20a%20browser%20extension%20that%20does%20this%2C%20or%20you'd%20need%20to%20change%20the%20server%20such%20that%20it%20has%20a%20mechanism%20to%20accept%20the%20Auth%20data%20from%20the%20URL%20or%20a%20POST%20body.%3C%2FLINGO-BODY%3E
Kamal1315
New Contributor

Hi,

We need to launch Edge (Chromium) using 'System.Diagnostics.Process' with header to target URL request.
My code is -  Process.Start("microsoft-edge:" + <url>);
Which work and open the Edge with url argument.

How can I pass a request header to the url.

Thanks 

3 Replies

@Kamal1315 In general, you should avoid launching a user's browser using a protocol handler wrapper (like "microsoft-edge:") and should instead just pass the URL (e.g. "https://www.foo/"). This will ensure that the user's default browser opens and handles the link. The default browser is more likely to work correctly vs a browser that is not their default (which might not have correct proxy settings, extensions, VPN, account info, etc).

 

To the other part of your question, no, there's no standard for opening a browser and passing headers or POST body information as a part of the initial request. There are ways to do this in certain browsers (e.g. Internet Explorer using COM invocation) but no reliable cross-browser standard. Instead, there are two possible routes:

 

1. Write a local HTML file that contains a form that automatically submits the desired data to the target server. This will allow sending of POST requests, etc.
2. Write a remote HTML file (e.g. on your server) that contains a form that automatically submits the desired data to the target server. This will allow sending of POST requests, etc.

 

Neither of these approaches is likely to allow you to pass a header to the target, insofar as there's no standard way in the web platform to "Navigate with header". That restriction exists mostly for security reasons.

 

What header do you need to pass, to what service or server? Do you control the service/server? Must the data be in a header vs. a POST body or Query Parameter on the URL?

@ericlawThanks Eric for reply.
Please see my comments for your query - 
[What header do you need to pass, to what service or server? Do you control the service/server? Must the data be in a header vs. a POST body or Query Parameter on the URL?] 
=> We need to pass authentication header to our own server's hosted web application.
Authentication details are normally sent via header only, so no post body or query string parameter.

@Kamal1315 Yeah, unfortunately this ("Add a header to a navigation request") isn't a capability present in the web platform. You could write a browser extension that does this, or you'd need to change the server such that it has a mechanism to accept the Auth data from the URL or a POST body.
Related Conversations
Dark new tab
UltraPako in Discussions on
12 Replies
Portable variant of Edge-Chromium
random_user in Discussions on
1 Replies