Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

NotSupportedException - System.Net.WebRequest.GetCreator

Discussion in 'Editor & General Support' started by felipeluis, Jun 6, 2009.

  1. felipeluis

    felipeluis

    Joined:
    Jun 6, 2009
    Posts:
    1
    Hi, I'm getting this annoying exception when trying some web requests in Unity's editor. The exception is: "NotSupportedException - System.Net.WebRequest.GetCreator (System.String prefix)". I get this when using SoapHttpClientProtocol, WebClient or WebRequest in different occasions. But the thing is that in the builded windows version it works just fine.

    Looking at the WebRequest implementation, I noted that this exception is thrown if the prefix of the requested URL is not supported (in this case, http). However, by searching for references for the class I found several occurrences in "machine.config" files under Unity's folder, which describes all available web modules (http, https, ftp, etc) and should be added as prefixes to the WebRequest class. Which makes me wonder if the editor is suppose to load those configs (or any other?).

    An example stack:

    NotSupportedException: http://localhost:3900/my-services/features/dbpoc/dbpoc.asmx
    System.Net.WebRequest.GetCreator (System.String prefix)
    System.Net.WebRequest.Create (System.Uri requestUri)
    System.Web.Services.Protocols.WebClientProtocol.GetWebRequest (System.Uri uri)
    System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest (System.Uri uri)
    System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest (System.Uri uri)
    System.Web.Services.Protocols.SoapHttpClientProtocol.GetRequestForMessage (System.Uri uri, System.Web.Services.Protocols.SoapClientMessage message)
    System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] parameters) [0x00000]
    my_client_glue.DBpoc.DBpoc.GetPlayers ()
    (wrapper remoting-invoke-with-check) my_client_glue.DBpoc.DBpoc:GetPlayers ()
    DBClient.OnGUI () (at Assets\features\db\test\DBClient.cs:17)


    Someone can help me?
     
  2. Lucas Meijer_old

    Lucas Meijer_old

    Joined:
    Apr 5, 2008
    Posts:
    436
    This is a bug in the Unity Editor and the Unity Webplayer. The only way to work around this is to somehow use the UnityEngine.WWW class instead of System.Net.WebClient

    Good luck, Lucas
     
  3. ashish1405

    ashish1405

    Joined:
    Jan 6, 2011
    Posts:
    16
    hello felipeluis,

    were you able to find a solution to this? I'm getting same error when trying to consume a WSDL thru a cs file.

    Thanks
    Ash
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    While this thread has nothing to do with Unity 3 (its 2009 -> unity 2.1 to unity 2.5) I would like to answer it in relation to U3


    You can not use WebRequest namespace on anything but standalone windows - osx
    On webplayer its not supported for crossdomain security reasons at all in Unity 3, not a bug. If you want to do requests, you must use WWW or implement it yourself on TCP Client / TCP Socket
     
  5. MatRon

    MatRon

    Joined:
    Jan 14, 2011
    Posts:
    16
    Hi Dreamora, can i use WebRequest on an iOS app? I am behind a proxy and i understand I cannot use WWW. Thanks
     
  6. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    I might be blind, but the only notes that are even remotely related to this write it in red, not green, for webplayers or anything but standalone with full .NET 2.0 set
     
    Last edited: Jul 11, 2011
  8. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
    You tell me...

    (I suppose you did not wait enough time for the whole page to download - it is a huge table)
     

    Attached Files:

  9. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Potentially didn't wait well enough or it just killed the search feature of chrome with its sheer amount.

    That being said I'm unsure if that list still holds for 3.1+
     
  10. GuyTidhar

    GuyTidhar

    Joined:
    Jun 24, 2009
    Posts:
    320
    Well anyways, I have gone and bought UniWeb, which is an Asset Store package that has an alternative http solution enabling you to use gzip for decompressing responses and use headers for GET requests.
    It also proved better in working with heavy load of communication.

    I Highly recommend it if anyone looks for a better http solution then what the WWW class currently offers.

    (It is supposed to work on iOS too and it works great in the webplayer).
     
  11. rterranova

    rterranova

    Joined:
    Nov 6, 2009
    Posts:
    43
    Just to make sure. WebRequests will NOT work with Mac - osx universal standalone?

    I'm trying to build a MAC OS X Universal app and I get the same sort of issue as stated above.

    NotSupportedException: http://records.byuview.com/richard/api1
    at System.Net.WebRequest.GetCreator (System.String prefix) [0x00000] in <filename unknown>:0
    at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in <filename unknown>:0
    at CookComputing.XmlRpc.XmlRpcClientProtocol.GetWebRequest (System.Uri uri) [0x00000] in <filename unknown>:0
    at CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke (System.Object clientObj, System.Reflection.MethodInfo mi, System.Object[] parameters) [0x00000] in <filename unknown>:0
    at CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke (System.Reflection.MethodInfo mi, System.Object[] Parameters) [0x00000] in <filename unknown>:0
    at XmlRpcProxy6a1fcd82-d04a-490a-90dd-962d25aaae6c.GetAllLevels () [0x00000] in <filename unknown>:0
    at LevelData+$LoadOrgs$263+$.MoveNext () [0x00000] in <filename unknown>:0
    UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
    $:MoveNext()
     
  12. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    At the time it seems that WebRequest seems not to work anywhere (Unity 3.3 3.4 at least)
     
  13. rterranova

    rterranova

    Joined:
    Nov 6, 2009
    Posts:
    43
    I'm currently using 3.3 and it's working with my PC Standalone but not with the MAC. Both work fine in the editor of course.

    Is this what you would expect at this time?

    3.4 is causing me all sorts of issues. I have not had time to sort through them all.
     
    Last edited: Aug 3, 2011
  14. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601

    Thats what I would expect at the time yes. Not what I would expect from the .NET Framework listing on the page and where its meant to work but from experience and other dev reports its in line.
    If you can resort to WWW, my strong recommendation is to go with it, its the one supported way to do it.

    If you target standalones only, UniWeb on the assetstore might be another alternative. I mention standalone cause it relies on TCP Socket which in webplayer naturally don't work as a webserver will normally not have a silverlight / unity policy server running
     
  15. rterranova

    rterranova

    Joined:
    Nov 6, 2009
    Posts:
    43
    Sorry, but are you saying that WebRequests will NOT work with Mac - osx universal standalone?

    Or it will eventually work, they will need to address this as a bug?
     
  16. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Thats a thing for UT to decide if its a bug or if they are going to cut System.Web completely as it never worked as listed in the namespace list on the website, at least to my knowledge
     
  17. felipeengel

    felipeengel

    Joined:
    Nov 22, 2011
    Posts:
    1
    Hi, does anybody found a solution or workaround for this to work on a osx standalone? I have already implemented all the functionality with the WebRequests and System.Web, and would prefer not to port all the classes to use the www class.

    Thanks in advance,
    fE
     
  18. Mohican

    Mohican

    Joined:
    May 17, 2012
    Posts:
    49
    If you want to force people into using the WWW class, can you please make it more complete?

    Here's a typical example of limitation: Checking a URL file size before downloading it.
    Check out this code:

    Code (csharp):
    1.  
    2.         // Check size of Remote Scene Bundle
    3.         var sceneURL:String = bundlesURL+scene+".unity3d";
    4.         var remoteSize:int = 0;
    5.         try {
    6.             var request:WebRequest = WebRequest.Create(sceneURL);
    7.             request.Method = "HEAD";
    8.             var response:WebResponse = request.GetResponse();
    9.             remoteSize = response.ContentLength;
    10.         } catch(err) {
    11.             remoteSize = 0;
    12.             Debug.Log(err);
    13.         }
    14.            
    15.         // Compare with local version
    16.         var download:WWW;
    17.         var localSize = PlayerPrefs.GetInt(scene+".size", 0);
    18.         if (remoteSize  remoteSize != localSize) {
    19.             // Download remote file
    20.             PlayerPrefs.SetInt(scene+".size", remoteSize);             
    21.             download = WWW.LoadFromCacheOrDownload(sceneURL, remoteSize);
    22.         } else {
    23.             // Load cached file
    24.             download = WWW.LoadFromCacheOrDownload(sceneURL, localSize);
    25.         }
    26.  
    This code works in Stand-Alone but not the WebPlayer.
    And there is no way I can make it work in WebPlayer using only the WWW Class.

    Can you please do something about it in the next 4.0 release???
     
  19. Mohican

    Mohican

    Joined:
    May 17, 2012
    Posts:
    49
    Just noticed this module on the Asset Store: http://u3d.as/content/different-methods/uni-web/1Cw

    But honestly, it feels unfair and stupid to spend $55 on restoring basic ".Net" functionality in the WebPlayer...
    Unity is great most of the time, but then stuff like that happens that makes you think: what the hell???


    Edit1: Also found this: https://code.google.com/p/unityweb/
    (The asset store package seems to be based on this).

    Edit2: Both the asset store and project above require the webserver to run a socket policy server (they are not compatible with a simple crossdomain.xml file). This thing is driving me nuts...!
     
    Last edited: Jan 13, 2013
  20. cdiflora

    cdiflora

    Joined:
    Jan 31, 2013
    Posts:
    3
  21. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    That's because they use sockets to implement the http/port80 connection. Using sockets requires a socket policy server, even if they are actually doing port 80 work.
     
  22. cboxgo

    cboxgo

    Joined:
    Oct 9, 2014
    Posts:
    8
    I know this is an old thread, but I had the same problem and it was due to my stripping option. It was set to 'use micro mscorlib' so I disabled stripping. Now, I have no problems using HttpWebRequest...
     
  23. joyjeba28

    joyjeba28

    Joined:
    Nov 30, 2015
    Posts:
    3
    I have got the following error when trying to download the file from Url..
    How to solve this..
    does anybody have a solution for this??? Thank you
    NotSupportedException: http://54.zzz.xxx.yyy/images/assetbundles/v6/android/assets
    at System.Net.WebRequest.GetCreator (System.String prefix) [0x00000] in <filename unknown>:0
    at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in <filename unknown>:0
    at System.Net.WebRequest.Create (System.String requestUriString) [0x00000] in <filename unknown>:0
    at RemoteFile..ctor (System.String remoteFile, System.String localFile) [0x00000] in <filename unknown>:0
    at test+<InstantiateAsset>c__Iterator5.MoveNext () [0x00000] in <filename unknown>:0
    UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    <StartProcess>c__Iterator4:MoveNext()
     
  24. Termitos

    Termitos

    Joined:
    Jun 10, 2015
    Posts:
    2
    Try switching Api Compatibility Level from .Net 2.0 Subset to .Net 2.0 in the Player Settings.
     
  25. faneric

    faneric

    Joined:
    May 15, 2013
    Posts:
    10
    Thanks a lot! Perfectly solved my problem!
     
  26. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    I get this same issue when I use code stripping. Isn't there a way to reduce build size, but make sure WebClient still works? Atm the only way is disabling stripping, but I like stripping. I know this is a 13 year old thread, but the issue still persists.