TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kow feng
NA
2
1.2k
How can I check all request url and return a custom object.
Sep 15 2018 5:09 AM
For example, when the URL request match (ex: .check) at the last of the URL, the server will return an object.
This should skip 404 error which means when I don't have the file in the server, it will still return an object no matter is an empty object.
Example:
www.localhost.com is my domain
1. www.localhost.com/testing.check (do not have this file exists) should return a custom object
2. www.localhost.com/testing/asdp.check (whether or not the path is exist, i just need the match of the last few words with .check) - return a custom object
Currently, im using Global.asax to check on Application_BeginRequest. However, it will hit 404 error when i only put domainname/{somethg}.check
Code as below:
protected void Application_BeginRequest(object sender, EventArgs e)
{
string url = HttpContext.Current.Request.Url.AbsoluteUri;
Regex regex = new Regex(@".*\/.*\.check$");
Match match = regex.Match(url);
if (match.Success)
{
Response.Redirect("https://www.google.com");
}
else
{
Response.Redirect("https://www.youtube.com");
}
}
Wish someone can help with this. Thanks in advance. If the question is not clear, please feel free to ask for details.
Reply
Answers (
1
)
DIsplay Information Popup Bootstrap Model
how to create digital sihnature