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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:35:50+00:00 2026-05-23T01:35:50+00:00

Working on an ASP.NET MVC 3 (Razor) application, that’s mainly concerned with UGC (user

  • 0

Working on an ASP.NET MVC 3 (Razor) application, that’s mainly concerned with UGC (user generated content).

I’m working on a “Q&A” area – where users can ask questions, others can answer, vote, etc.

As such, i’m trying to figure out a clean way to handle the available operations a user can do on any given page, based on their role and other factors.

Take the scenario of the “Question Detail Page” (like this page on Stack Overflow).

Any (authenticated) user can:

  • Vote for question/answer
  • Answer

Question owner can:

  • Edit
  • Delete
  • Mark answer

And so forth.

Now, i have a QuestionViewModel, that is used to display the question and relevant answers for this particular View.

I create it using AutoMapper.

How can i display “stickies” (e.g hyperlinks) on the page, based on the available operations?

My current thinking is:

  • I create an enum: QuestionOperation (Answer, Edit, Disable, Vote, Answer, etc)
  • I add a property of type IEnumerable<QuestionOperation> to my ViewModel
  • I set this property in my action method (HTTP GET), checking if the user is authenticated and the roles they are a part of.
  • I then use an editor template to render out each operation as a hyperlink, using Html.ActionLink

Is that considered a clean approach – or can anyone suggest a better one?

Keeping in mind i am re-using this QuestionViewModel on three pages:

  1. The question detail page
  2. The “Ask a question” page
  3. The “Edit a question” page

So because these operations are page/user dependant, it can’t really be done with AutoMapper.

  • 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-23T01:35:51+00:00Added an answer on May 23, 2026 at 1:35 am

    I would setup a separate controller and action which will be returning a partial view containing the necessary links. Then I would use the Html.Action helper to include it from the main view.

    Something among the lines:

    public class UserLinksController: Controller
    {
        // TODO: ctor DI of a repository, etc...
    
        public ActionResult Index(string questionId)
        {
            string username = User.Identity.IsAuthenticated 
                ? User.Identity.Name : string.Empty;
            var roles = _repository.GetRolesForQuestion(username, questionId);
            var model = Mapper.Map<UserRoles, RolesViewModel>(roles);
            return PartialView(model);
        }
    }
    

    and in the corresponding partial you would check the view model and render the necessary links:

    @model RolesViewModel
    @if(Model.CanEdit)
    {
        @Html.ActionLink("Edit", "Edit", "Questions")    
    }
    @if(Model.CanDelete)
    {
        @Html.ActionLink("Delete", "Delete", "Questions")    
    }
    ...
    

    Now somewhere in your main view simply include this action using the Html.Action method:

    @Html.Action("Index", "UserLinks", new { questionId = Model.QuestionId })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As I am learning and working on Asp.Net MVC application, I want to know
I have a asp.net mvc application and am trying to get custom errors working
I am working with ASP.NET MVC and have a view page with a simple
I'm working with ASP.NET MVC but this really applies to any MVC framework. I
I am working in ASP.Net MVC 1.0 and SQL Server 2000 using Entity Framework.
I'm currently working with ASP.NET and about to start learning ASP.NET MVC (2). So
I have an issue that appears in all browsers. I am working with ASP.NET
I'm working on an ASP.NET MVC Multi Tenancy app. Right now I managed to
I'm working on an ASP.NET MVC app, designing the domain models, using (testing) the
I am working on an ASP.NET MVC project which allows users to construct arbitrarily

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.