using on azure project

Dec 28, 2010 at 12:33 PM

Joe hi,

Today I tried porting the mvc app to a cloud app(azure). I just created a cloup app and added the mvc app to it.

When I click the link first time to go to twitter for authentication, I got this error:

System.Configuration.ConfigurationErrorsException was unhandled by user code  Message=Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section.  Source=System  BareMessage=Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section.  Line=0  StackTrace:       at System.Net.Configuration.DefaultProxySectionInternal.GetSection()       at System.Net.WebRequest.get_InternalDefaultWebProxy()       at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)       at System.Net.HttpRequestCreator.Create(Uri Uri)       at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)       at System.Net.WebRequest.Create(String requestUriString)       at LinqToTwitter.OAuthTwitter.WebRequest(HttpMethod method, String url, String authHeader, String postData) in D:\projects\0312\LinqToTwitterSource_v2.0.17\LinqToTwitter\LinqToTwitterAg\OAuth\OAuthTwitter.cs:line 375       at LinqToTwitter.OAuthTwitter.oAuthWebRequest(HttpMethod method, String url, String postData, String callback) in D:\projects\0312\LinqToTwitterSource_v2.0.17\LinqToTwitter\LinqToTwitterAg\OAuth\OAuthTwitter.cs:line 358       at LinqToTwitter.OAuthTwitter.AuthorizationLinkGet(String requestToken, String authorizeUrl, String callback, Boolean readOnly, Boolean forceLogin) in D:\projects\0312\LinqToTwitterSource_v2.0.17\LinqToTwitter\LinqToTwitterAg\OAuth\OAuthTwitter.cs:line 84       at LinqToTwitter.WebAuthorizer.BeginAuthorization(Uri callback) in D:\projects\0312\LinqToTwitterSource_v2.0.17\LinqToTwitter\LinqToTwitterAg\OAuth\WebAuthorizer.cs:line 54       at LinqToTwitter.MvcOAuthActionResult.ExecuteResult(ControllerContext context) in D:\projects\0312\LinqToTwitterSource_v2.0.17\LinqToTwitter\LinqToTwitter\OAuth\MvcOAuthActionResult.cs:line 26       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass14.<InvokeActionResultWithFilters>b__11()       at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)  InnerException: System.TypeInitializationException       Message=The type initializer for 'RasHelper' threw an exception.       Source=System       TypeName=RasHelper       StackTrace:            at System.Net.UnsafeNclNativeMethods.RasHelper.GetCurrentConnectoid()            at System.Net.AutoWebProxyScriptEngine.AutoDetector.Initialize()            at System.Net.AutoWebProxyScriptEngine.AutoDetector.get_CurrentAutoDetector()            at System.Net.AutoWebProxyScriptEngine..ctor(WebProxy proxy, Boolean useRegistry)            at System.Net.WebProxy.UnsafeUpdateFromRegistry()            at System.Net.WebProxy..ctor(Boolean enableAutoproxy)            at System.Net.Configuration.DefaultProxySectionInternal..ctor(DefaultProxySection section)            at System.Net.Configuration.DefaultProxySectionInternal.GetSection()       InnerException: System.TypeInitializationException            Message=The type initializer for 'System.Net.ComNetOS' threw an exception.            Source=System            TypeName=System.Net.ComNetOS            StackTrace:                 at System.Net.UnsafeNclNativeMethods.RasHelper.InitRasSupported()                 at System.Net.UnsafeNclNativeMethods.RasHelper..cctor()            InnerException: System.Configuration.ConfigurationErrorsException                 Message=Required attribute 'type' not found. (C:\Users\ASUS\Documents\Visual Studio 2010\Projects\GiftSocialAzure\MvcGiftSocial\web.config line 11)                 Source=System.Configuration                 BareMessage=Required attribute 'type' not found.                 Filename=C:\Users\ASUS\Documents\Visual Studio 2010\Projects\GiftSocialAzure\MvcGiftSocial\web.config                 Line=11                 StackTrace:                      at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)                      at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)                      at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)                      at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)                      at System.Web.Configuration.HttpConfigurationSystem.GetApplicationSection(String sectionName)                      at System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName)                      at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)                      at System.Configuration.ConfigurationManager.GetSection(String sectionName)                      at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)                      at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()                      at System.Diagnostics.DiagnosticsConfiguration.Initialize()                      at System.Diagnostics.DiagnosticsConfiguration.get_Sources()                      at System.Diagnostics.TraceSource.Initialize()                      at System.Net.Logging.InitializeLogging()                      at System.Net.Logging.get_On()                      at System.Net.ComNetOS..cctor()                 InnerException: 

 

Is there something in azure which does not allow this or am i doing something wrong?

Thanks and best regards

Arnab 

Coordinator
Dec 28, 2010 at 8:02 PM

Hi Arnab,

Looking at the stack trace, I'm not sure.  It seems to be some type of Azure configuration issue associated with HTTP requests.  A quick search, "http://www.bing.com/search?q=Azure+Error+creating+the+Web+Proxy+specified+in+the+'system.net%2fdefaultProxy'+configuration+section&src=IE-SearchBox&first=11&FORM=PORE", yielded several clues.

Joe

Dec 31, 2010 at 3:41 AM

Joe hi,

tried everything still not working, even connected with the local ms guys working on azure.

Please do let know if you find something.

Thanks 

Arnab

Dec 31, 2010 at 4:13 AM

Joe, 

The primary problem seems to be in oAuthTwitter:

  public string WebRequest(HttpMethod method, string url, string authHeader, string postData)        {    

       HttpWebRequest webRequest = null;        

   string responseData = "";


            webRequest = System.Net.WebRequest.Create(ProxyUrl + url) as HttpWebRequest;          

 webRequest.Method = method.ToString();

 

The proxyurl value is coming as null and it is throwing the error.

 

Thanks

 

Coordinator
Dec 31, 2010 at 6:15 AM

Arnab,

If that's the case then the quick fix is to set ProxyUrl on the Authorizer to an empty string, like this:

            var auth = new PinAuthorizer
            {
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"]
                },
                //UseCompression = true,
                GoToTwitterAuthorization = pageLink => Process.Start(pageLink),
                GetPin = () =>
                {
                    // this executes after user authorizes, which begins with the call to auth.Authorize() below.
                    Console.WriteLine("\nAfter you authorize this application, Twitter will give you a 7-digit PIN Number.\n");
                    Console.Write("Enter the PIN number here: ");
                    return Console.ReadLine();
                },
                ProxyUrl = string.Empty
            };

See the last line where I set ProxyUrl to an empty string.  This is using the PinAuthorizier, but it will work on all the Authorizers.

Thanks for finding this.  I'll put in a fix that makes ProxyUrl default to an empty string.

Coordinator
Dec 31, 2010 at 6:16 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.