我可以使用相同的标题找到更多错误。但没有给出我的解决方案。我试图创建小应用程序来获取用户位置,并反转它。一切都很好,工作得很好。当我用我的电脑测试并发布它工作正常,没有任何错误。现在我尝试把它放在另一台电脑(IIS)试图从我的电脑应用程序运行完美访问,但当它达到读取它抛出上述错误的位置。我做了一些谷歌大多数人都说认证问题,或超时问题。但它在我的电脑工作完美甚至在(IIS),我尝试从其他笔记本电脑和所有工作良好。
Server Error in '/' Application.
The remote server returned an error: (400) Bad Request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[WebException: The remote server returned an error: (400) Bad Request.]
System.Net.HttpWebRequest.GetResponse() +1695
System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) +105
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +86
System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) +71
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) +0
System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) +112
System.Xml.XmlTextReaderImpl.OpenUrl() +396
System.Xml.XmlTextReaderImpl.Read() +296
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +158
System.Xml.XmlDocument.Load(XmlReader reader) +134
System.Xml.XmlDocument.Load(String filename) +146
WiseDistribution.Settings.usrProfile.getlocationname() in D:\Projects\UserLocation\Settings\usrProfile.aspx.cs:190
WiseDistribution.Settings.usrProfile.imgUpdate_Click(Object sender, ImageClickEventArgs e) in D:\Projects\UserLocation\Settings\usrProfile.aspx.cs:152
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +138
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +186
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1665
这是我得到的错误。
我的配置文件是。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
Connection string
</appSettings>
<connectionStrings>
<add name="Excel03ConString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR={1}'" />
<add name="Excel07ConString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0;HDR={1}'" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
</controls>
</pages>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
</authentication>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
真的不知道问题出在哪里。所有位置跟踪按钮单击返回相同的错误。同时如果我尝试从我的电脑调试(运行visual studio)我没有收到任何错误,即使我使用远程服务器数据库和webconfig文件。
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=abcdeff&callback=myMap"></script>
<script type="text/javascript">
$(document).ready(function () {
var longitude = $('#longitude');
var latitude = $('#latitude');
var hiddenControl = '<%= inpHide.ClientID %>';
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (p) {
console.log(longitude);
longitude.text(p.coords.longitude);
latitude.text(p.coords.latitude);
document.getElementById(hiddenControl).value=p.coords.latitude + "," + p.coords.longitude;
var LatLng = new google.maps.LatLng(p.coords.latitude, p.coords.longitude);
// alert(p.coords.latitude);
var mapOptions = {
center: LatLng,
zoom: 20,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
var marker = new google.maps.Marker({
position: LatLng,
map: map,
title: "<div style = 'height:60px;width:200px'><b>Your location:</b><br />Latitude: " + p.coords.latitude + "<br />Longitude: " + p.coords.longitude,
});
google.maps.event.addListener(marker, "click", function (e) {
var infoWindow = new google.maps.InfoWindow();
infoWindow.setContent(marker.title);
infoWindow.open(map, marker);
});
});
} else {
alert('Location feature is not supported in this browser.');
}
});
</script>
这是html端javascript代码
public void getlocationname()
{
// string coordinate = latitude.InnerText + "," + longitude.InnerText; // "32.797821,-96.781720";
string coordinate = inpHide.Value;
XmlDocument xDoc = new XmlDocument();
// xDoc.Load("https://maps.googleapis.com/maps/api/geocode/xml?latlng=" + coordinate);
xDoc.Load("https://maps.google.com/maps/api/geocode/xml?key=abcdff&callback&latlng=" + coordinate + "&sensor=false");
XmlNodeList xNodelst = xDoc.GetElementsByTagName("result");
XmlNode xNode = xNodelst.Item(0);
string FullAddress = xNode.SelectSingleNode("formatted_address").InnerText;
string Number = xNode.SelectSingleNode("address_component[1]/long_name").InnerText;
string Street = xNode.SelectSingleNode("address_component[2]/long_name").InnerText;
string Village = xNode.SelectSingleNode("address_component[3]/long_name").InnerText;
string Area = xNode.SelectSingleNode("address_component[4]/long_name").InnerText;
string County = xNode.SelectSingleNode("address_component[5]/long_name").InnerText;
locationName = FullAddress;
}
后面的代码获取位置名称(用于保存数据)