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 6039059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:18:46+00:00 2026-05-23T06:18:46+00:00

I have an Area named ‘Subscribers’ and a controller in that area named ‘SubscriptionsController’

  • 0

I have an Area named ‘Subscribers’ and a controller in that area named ‘SubscriptionsController’ with two public action methods: Index() and Unsubscribe() where the Unsubscribe() method is passed a subscriber id i.e. Unsubscribe(int id)

Under certain circumstances (the id is invalid for example), the Unsubscribe() method performs a RedirectToAction(“Index”) to the other action on the same controller.

public ActionResult Index()
{
    return View();
}

if I access the page via ‘/Subscribers/Subscriptions/Unsubscribe/999’ the the RedirectToActionMethod() correctly redirects me to the Index() action.

I wanted to be able to ‘shortcut’ the formal url (‘/Subscribers/Subscriptions/Unsubscribe/999’) so I added a route to the Global.ascx file:

routes.MapRoute(
    "Unsubscribe",
    "Unsubscribe/{id}",
    new {area = "Subscribers", controller = "Subscriptions", action = "Unsubscribe"}
);

This route appears to work correctly as it runs the Unsubscribe() method as expected. The problem I have is the calls to RedirectToAction(“Index”) within Unsubscribe() now fail as they whilst they still invoke the correct action (Index()), the view engine now disregards the Area and tries to load a view relative to the root of the web site ‘~/Views/Subscriptions/Index.aspx’ instead of ‘~/Areas/Subscribers/Views/Subscriptions/Index.aspx’

I can fix this by modifying the RedirectToAction() method in the Unsubscribe() method thus:

return RedirectToAction("Index", "Subscriptions", new { Area = "Subscribers" });

but this seems like a cumbersome and not very flexible solution to the problem.

Any advice or explanation would be much appreciated.

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-23T06:18:47+00:00Added an answer on May 23, 2026 at 6:18 am

    I think I have fixed the problem.

    The routing needs to go in the Area’s RegisterArea method:

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Subscribers_unsubscribe",
            "Unsubscribe/{id}",
            new { controller = "Subscriptions", action = "Unsubscribe", id = UrlParameter.Optional }
        );
    
        context.MapRoute(
            "Subscribers_default",
            "Subscribers/{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I have controller named Snippets both in default area (in application
I have two spinners one named cuisine and other area. I m calling the
If I have a development area that I deleted files from a certain folder/directory,
I have a div (sub area of page with scroll bar) that has some
I have an accessibility skip nav menu that uses named anchors to jump to
I have a directory that is named admin. There is no physical path to
I have a page named index.html . On it, I have a menu with
I created an area named Admin. In /Areas/Admin/Views/, I have _ViewStart.cshtml with this: @{
I have a String field where I store two-word area names. Ex: New York
I have problem with generation of links I have an Area named Administration, it

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.