Bobby X
asked on
Invalid URI: The hostname could not be parsed
Could someone please tell me how I can resolve this error? This error that I've been receiving from my Production environment does not tell me exactly where or what page in my ASP.NET web app causes the error:
Invalid URI: The hostname could not be parsed.
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36
Many thanks in advance.
Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Web.Util.UriUtil.BuildUriImpl(String scheme, String serverName, String port, String path, String queryString, Boolean useLegacyRequestUrlGeneration)
at System.Web.HttpRequest.BuildUrl(Func`1 pathAccessor)
at System.Web.HttpRequest.get_Url()
at System.Web.Http.WebHost.HttpControllerHandler.ConvertRequest(HttpContextBase httpContextBase, IHostBufferPolicySelector policySelector)
at System.Web.Http.WebHost.Routing.HttpContextBaseExtensions.GetOrCreateHttpRequestMessage(HttpContextBase context)
at System.Web.Http.WebHost.Routing.HttpRouteExceptionHandler.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36
Many thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try write down the error into a log file for the ease of debugging, or you can open up the browser's Inspect tool for debugging, see which resources cannot be loaded or hitting the errors.
from the error stack trace, you should able to find the line number within your codes which triggered the error, don't you?
from the error stack trace, you should able to find the line number within your codes which triggered the error, don't you?
ASKER
The EmailToMyself() which sends the exception info to myself is located inside the Application_Error() of my Global.asax.cs (see below). Could someone please modify the code on Line 217 to include the page from which the error occurs?
protected void Application_Error(object sender, EventArgs e)
{
int statusCode = 500;
var ex = Server.GetLastError();
if (ex is HttpException)
{
var httpEx = ex as HttpException;
statusCode = httpEx.GetHttpCode();
}
if (statusCode != 404)
{
EmailToMyself(ex.Message + "<br/><br/>" + ex.InnerException + "<br/><br/>" + ex.StackTrace + "<br/><br/>" + Request.UserAgent); // Line 217
}
}
protected void Application_Error(object sender, EventArgs e)
{
int statusCode = 500;
var ex = Server.GetLastError();
if (ex is HttpException)
{
var httpEx = ex as HttpException;
statusCode = httpEx.GetHttpCode();
}
if (statusCode != 404)
{
EmailToMyself(ex.Message + "<br/><br/>" + ex.InnerException + "<br/><br/>" + ex.StackTrace + "<br/><br/>" + Request.UserAgent); // Line 217
}
}
Remove the unassigned Object: + Request.UserAgent from your upper Application_Error( ) function and show us the stack trace from next exception.
ASKER
Done. Will post the next stack trace when the exception occurs.
OK, thanks.
Open in new window
Has been passed as a URI, which won't work.
You must pass a well formed URI, like https://example.com for parsing to succeed.