asp.net 4.0 中 Catch() 的 URL 路由
我已在我的内容页面中写入
protected void Page_Init(object sender, EventArgs e)
{
try
{
Page.Title = "Bollywood Movie-" + Page.RouteData.Values["MovieName"].ToString();
int movieid = int.Parse(Page.RouteData.Values["MovieId"].ToString());
}
catch (Exception ex)
{
Response.RedirectToRoute("ErrorPage");
}
}
,但进入 catch 后,它不会重定向到错误页面,而是转到 page_load,然后转到 master 的 page_load,然后显示
Server Error in '/' Application.
输入字符串格式不正确的错误。 描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:System.FormatException:输入字符串的格式不正确。
怎么了???
I have written in my content page
protected void Page_Init(object sender, EventArgs e)
{
try
{
Page.Title = "Bollywood Movie-" + Page.RouteData.Values["MovieName"].ToString();
int movieid = int.Parse(Page.RouteData.Values["MovieId"].ToString());
}
catch (Exception ex)
{
Response.RedirectToRoute("ErrorPage");
}
}
but after going into catch it doesn't redirect to error page but it goes to page_load then page_load of master then it shows error of
Server Error in '/' Application.
Input string was not in a correct format.
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.FormatException: Input string was not in a correct format.
what is wrong???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在
application_start
事件中注册路由,以告诉服务器针对给定字符串调用哪个页面。在您的 Global.asax 文件中写入以下内容:
请参阅 此帖子了解更多详细信息。
You need to register the routes in
application_start
event to tell server which page to call for given string.In your
Global.asax
file write following:Please refer to this post for more details.