Patrick
Patrick

Reputation: 2781

Google API Key for MVC C# Class

What key type should I use from Google Dev Console for an MVC C# Class, when I try to make a Web Request Call?

"Key for browser applications" or "Key for server applications"?

MVC C# Code:

string url = @"https://maps.googleapis.com/maps/api/distancematrix/xml?key=" + key + "&origins=" + origin + "&destinations=" + destinations + "&mode=driving&sensor=false&language=pt-PT";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
WebResponse response = request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader sreader = new StreamReader(dataStream);
string responsereader = sreader.ReadToEnd();
response.Close();

XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(responsereader);

Upvotes: 1

Views: 1248

Answers (2)

user12053089
user12053089

Reputation:

You have developer keys and production keys, in development using developer keys and in production use production keys

Upvotes: 1

scott
scott

Reputation: 385

You should be using key for server applications.

Upvotes: 2

Related Questions