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

  • Home
  • SEARCH
  • 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 494693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:31:12+00:00 2026-05-13T05:31:12+00:00

I have an action in which I want to intercept any possible integer id

  • 0

I have an action in which I want to intercept any possible integer id that comes and place it behind a hash. (I have some Javascript that is handling the id). I am only doing this extra step for the sake of URL-hackers like me who might forget my convention of putting a hash before the id.

Here is my action:

public ActionResult Edit(int? id)
{
    if (id != null) return Redirect(Url.Action("Edit") + "/#" + id);

    return View();
}

The problem is that the Url.Action method is preserving the passed id. Url.Action(“Edit”) is returning “{controller}/Edit/{id}”. I want it to just return “{controller}/Edit”! (And my code is tacking on an additional “/#{id}”).

For example, a request to this URL:

http://localhost:2471/Events/Edit/22

is redirecting to this URL:

http://localhost:2471/Events/Edit/22/#22

when I want it to redirect to this URL:

http://localhost:2471/Events/Edit/#22

I’m frustrated. Does anyone know how to get a URL to the current action that doesn’t include the passed id?

  • 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-13T05:31:12+00:00Added an answer on May 13, 2026 at 5:31 am

    One way to do this would be to define a route for the controller action, eg the Route would be defined as “{controller}/{action}/”. Then use something similar to the following to build your actual URL:

    Url.RouteUrl("MyRoute") + "#" + id
    

    Not the best method, but it works. Maybe someday Microsoft will add fragment support to routing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an action which create QMessageBox. In that dialog I want to print
I have an action 'approval' that renders a view which displays some content from
I want to create a button which when clicked calls an action. I have
I have got Sinatra/Rails app and an action which starts some long process. Ordinary
I have a jquery routine that calls an MVC action which will do a
I have a action.php which does some processing involving a MySQL-Database. In action.php I
I have an action which is rendering some content via a layout. I actually
I have controller users . In this controller I have action account which is
I have got an action which takes in an argument it goes like this
I have an action in one of my controllers which creates a downloadable zip

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.