Ebeo / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

VS2008 web app with local IIS throws an exception #357

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello Everyone!

I'm currently working on a project that is for synchronizing different 
calendars. One of these is the google calendar.

To be familiar with the gdata methods and the likes, i just wanted to 
display the calendars for my test account, so nothing special.

If i create a console app, everything is ok, i can see the calendar names. 
If im using web app (and that's what i need to use), at the very beginning 
i get an exception, if i set the app properties to use 'Local IIS Web 
server', however, if i set 'Use Visual Studio Development Server', 
everything is ok and i can display the calendar names. The difference that 
i noticed is that the 'HttpContext.Current.User.Identity.Name' is an empty 
string when local iis is used, but <xy>\<myusername> when im using the vs 
dev server.
This is the code that im using (zhis is just a test code in a totally test 
app):
...
string username = "ixsyncuser";
string pwd = <the necessary password as a string>;

CalendarService service = new CalendarService("exampleCo-exampleApp-1");
service.setUserCredentials(username, pwd);

FeedQuery query = new FeedQuery();
query.Uri = new Uri("http://www.google.com/calendar/feeds/default");
AtomFeed calFeed = service.Query(query);

for (int i = 0; i < calFeed.Entries.Count; i++)
{
   //lbEvents is a listbox for displaying the data
   lbEvents.Items.Add(new ListItem(calFeed.Entries[i].Title.Text,
      i.ToString()));
}
...

So, its nothing special. The exception is occuring at the row :
"AtomFeed calFeed = service.Query(query);"

And these are the errormessages from the exception :

"Execution of request failed: http://www.google.com/calendar/feeds/default
InnerException : {"The underlying connection was closed: An unexpected 
error occurred on a receive."}"

Does anybody know what is wrong? May i need to set something special in 
iis? Or this is not the correct way for working with calendars in a web 
app?

Thanks in advance for any help!

Cheers,
Daniel

Original issue reported on code.google.com by ixsyncu...@gmail.com on 23 Mar 2010 at 5:08

GoogleCodeExporter commented 9 years ago
Hi again!

We have the solution, finally! :) The problem lies within the IIS settings, 
because 
Local Impersonization was not set on my pc. As i set the domain\username + my 
password, the code below begun to work.

string username = "<username>";
string pwd = "<password>";
CalendarService service = new CalendarService("exampleCo-exampleApp-1");
service.setUserCredentials(username, pwd);
((GDataRequestFactory)service.RequestFactory).KeepAlive = false;
GDataRequestFactory requestFactory = 
(GDataRequestFactory)service.RequestFactory;
WebProxy myProxy = new WebProxy("<your proy setting, like xxx.xxx.xx.xx:port/", 
true);
myProxy.Credentials = CredentialCache.DefaultCredentials;
myProxy.UseDefaultCredentials = true;
requestFactory.Proxy = myProxy;
FeedQuery query = new FeedQuery();
query.Uri = new Uri("http://www.google.com/calendar/feeds/default");
AtomFeed calFeed = service.Query(query);

for (int i = 0; i < calFeed.Entries.Count; i++)
{
   lbEvents.Items.Add(new ListItem(calFeed.Entries[i].Title.Text, i.ToString()));
}

I hope it will help for those who encountered this problem! :)

Cheers,
Daniel

Original comment by ixsyncu...@gmail.com on 24 Mar 2010 at 3:52

GoogleCodeExporter commented 9 years ago
Thank you for posting the solution for this. 

Frank Mantek
Google

Original comment by fman...@gmail.com on 7 Jun 2010 at 2:46