'System.Net.FileWebRequest' can not be casted to 'System.Net.HttpWebRequest' on remote machine, but works locally

The URI being passed in is not an http URI -- it's either just a path or a file URI. Ensure the URI starts with http:. If it's a relative URI, you'll need to make it absolute.

WebRequest is the type returned by WebRequest.Create() factory method, and is an abstract type.

According to the protocol recognized in the URL string, it returns you a valid subclass, like FileWebRequest or FtpWebRequest.

The problem in your code is that you are trying to create a request for a local file (file://) protocol, so the factory returns FileWebRequest, but you are forcing the code to think it's are remote HTTP URL. Simply wrong.

This explains the fact that it works only with remote and not local files


  1. Messiah

    • 2016/7/31

    The origins of the ampersand, how it has evolved, the various types in use in contemporary typography and famous logos that make use of it.

  2. Kendrick

    • 2017/4/7

    Ampersand definition is - a character typically & standing for the word and. How to use ampersand in a sentence. Did you know?

  3. Jake

    • 2020/2/18

    U+FE60, ﹠ HEAVY AMPERSAND ORNAMENT The roman ampersand at left is stylized, but the italic one at right reveals its origin in the Latin word 

  4. Remi

    • 2019/2/28

    Ampersand is the string concatenation operator in many BASIC dialects, AppleScript, Lingo, HyperTalk, and FileMaker. In Ada it applies to all one-dimensional arrays, not just strings. BASIC-PLUS on the DEC PDP-11 uses the ampersand as a short form of the verb PRINT.

  5. Allen

    • 2016/2/13

    In the 19th century, the ampersand (&) was considered the 27th letter of the alphabet. Ampersand gets its name from the phrase '& per se, and,' meaning 

  6. Ferrari

    • 2016/12/27

    An ampersand is a symbol (&) representing the word and. The ampersand was included in the Old English alphabet, and the term is an alteration of and per se and. The symbol is a combination (or ligature) of the letters in et, Latin for "and." In formal writing, the ampersand is primarily used in the names of companies, such as "Johnson & Johnson."

  7. Mohammad

    • 2019/4/12

    Ampersand definition is - a character typically & standing for the word and. How to use ampersand in a sentence. Did you know?

  8. Raphael

    • 2021/5/24

    The Ampersand is used for " and " and its symbol is a logogram, &. A logogram (or logograph) is a written symbol that represents a whole word or a phrase. The origin of the ampersand comes from the Latin conjunction "et", meaning "and". This symbol is a ligature of these lowercase letters, "e" and "t". So, this aesthetic logogram called "short

  9. Michel

    • 2020/4/23

    Shop deals on unlimited data plans, Internet service, and DIRECTV STREAM. Get 24/7 support & manage your account online. Buy the new iPhone 13 from AT&T.

  10. Izaiah

    • 2020/2/18

    ampersand definition: 1. the sign &, used for "and" 2. the sign &, used for "and". Learn more.

  11. Rayan

    • 2018/9/30

    Darice Paper Mache Symbol for Craft or Display - Ampersand - 12 Inches x 8.5 Inches x 1.5 Inches. 4.5 out of 5 stars. 12. $9.95. $9. . 95. Get it as soon as Thu, May 20. FREE Shipping on orders over $25 shipped by Amazon.

  12. Hayden

    • 2019/3/19

    Ampersand. MOVING TV FORWARD. Bringing together brands and audiences, content and distribution, insights and measurement. We simplify a marketer’s ability to plan, activate and measure their TV investments. Get to know us. The AND Platform. Define + Find. Plan + Execute. Measure + Report.

Comments are closed.

Recent Posts