Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7055841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:47:48+00:00 2026-05-28T03:47:48+00:00

I think question is clear. I want to handle url strings which can be

  • 0

I think question is clear. I want to handle url strings which can be added by user.

Example;

http://download.cnet.com/windows/script alert('hello') /script

or

http://download.cnet.com/windows/aaaaaaaaaaaaa

As you can see in examples, cnet handle these inputs and redirect user to custom 404 file.

I’m working on mvc3 razor, it’s something with controller I suppose, but I can’t make it.

Extra Information:
What I want to do; I want to handle or external string which can be added end of the url.
Another example; http://www.yazilimdevi.com/yazilimdevi/aaaaaaaaa
As you can see, if user input “aaaaaa” to end of url; he/she see “Server Error in Application” which was prepared by IIS. I want to create a custom page, and redirect all users who added unknown path, string or script…

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:47:49+00:00Added an answer on May 28, 2026 at 3:47 am

    If you want to implement special handling for this scenario then you may want to add new route using /{*arbitrary_url_part} scheme. For example, route

            routes.MapRoute(
                "SampleRoute",
                "constant_path/{*variable_part}",
                new {controller = "ErrorController", action = "ShowError", variable_part = ""}
                );
    

    will match all those urls:

    http://Server_url/constant_path/ (variable_part==””)

    http://Server_url/constant_path/aaaaaaaaaaaaa (variable_part==”aaaaaaaaaaaaa”)

    http://Server_url/constant_path/script alert('hello') /script (variable_part==”script alert(‘hello’) /script”)

    etc. no matter how much slashes or other special symbols user puts in. For reference, see MSDN: ASP.NET Routing – Handling a Variable Number of Segments in a URL Pattern
    .

    If you don’t want to bother yourself with implementing all this stuff and only want to show a fancy 404 page to user then you might consider using standard ASP.NET feature – Custom error pages

    Other strategies on handling such requests can also be found in This blog post.

    UPDATE

    If you want to go the first way, you’ll also have to add controller and view for displaying some custom error page. If you take the same names as in route you’ll have to add following to your project:

    1. File Controllers/ErrorController.cs containing class ErrorController with method ShowError, like this:

      using System.Web.Mvc;
      
      namespace Your_app_name_here.Controllers
      {
          public class ErrorController : Controller
          {
              public ActionResult ShowError(string variable_part)
              {
                  return View((object)variable_part); // Cast to object is required here
              }
          }
      }
      
    2. File Views/Error/ShowError.aspx – a simple HTML view to display error information, like this:

      <%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
      <HTML>
      <HEAD><TITLE>Error page title here</TITLE></HEAD>
      <BODY>
      <H1>variable_part = <%=Model.ToString()%></H1>
      </BODY>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think the question title is clear enough: is is possible to stable_sort() a
I want to design a question structure with some comments. Which relationship should I
I think quesiton is clear. I'm programming with C# and using MySQLDriverCS to connect
Update I don't think I was clear enough when I originally posted this quesion.
I think the question says it all. I'm new to Eclipse plugin development, so
I think the question says it all. I have several monthly processes in stored
I think the question is pretty self explanatory. Anyone done this before? UPDATE :
I think my question is somewhat similar to CaptainPicard's but dissimilar enough that I
I think this question is rather easy for you shell scripting monsters. I am
I think the question is a bit silly, but for a newbie startup building

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.