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 a rails create action which send back some jquery in a file:
In my Rails application I have an action which creates a XML document using
I have a controller that has many actions and it specifies a default class-level
In a C#/ASP.NET application, I have a form that renders much like the following
Rails 3.0.3 ruby 1.9.2p0 The Problem: I have a Users table which has many
I have a subscription based MVC 2 application with the basic .NET Membership service
What would be the best way to intercept multiple fields via PHP? Currently I
I am working on a Windows service which needs to schedule tasks whenever one
I have just started working on a struts2 project. I have seen the power
I'm planning on using qActions for use globally in my application. The idea is

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.