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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:23:42+00:00 2026-05-31T23:23:42+00:00

Hi i am developing an application in MVC using nhibibernate. It is an Question-Answer

  • 0

Hi i am developing an application in MVC using nhibibernate.
It is an Question-Answer Forum where on the first Page a list of questions are displayed as link.Now when i click on the link it moves to the Answers Page where the answers are displayed for the particular Question.
I have two tables with the following fields

Question Table:

QuestionID int
Question nvarchar(255)
Created_Date datetime
Modified_Date datetime
Created_By int
Modified_By int
Deleted nchar(1)

Answers Table:

AnswerId int
Answer nvarchar(255)
Created_Date datetime 
Modified_Date datetime  
Created_By int 
Modified_By  int
QuestionID int (foreign key)
Deleted  nchar(1)

This is what i have tried:
Inside QuestionPage.cshtml

@using (Html.BeginForm("Question_Page","QuestionAnswer",FormMethod.Post))
{ 
@Html.ValidationSummary(true) 
<ul>
@foreach (var item in Model)
{
    <li>@Html.ActionLink(item.Question, "Answer_Page", new { Id = item.QuestionID, Question = item.Question })</li>
}
   </ul>

 <br />
<h2><label for="PostyourQuestion:">Post your Question:</label></h2>
 @Html.TextArea("PostyourQuestion")    
<br /><br />
<input type="submit"/>

}

Inside the Controller:

 public ActionResult Answer_Page(int Id, string Question)
   {
       var model = new AnswerService().GetAllAnswers();
       ViewBag.Question = Question;
       model = (from x in model
                where x.QuestionID.Equals(Id)
                select x).ToList();   

       return View(model);
   }
    [HttpPost]
   public ActionResult Answer_Page(Answers ans, string PostyourAnswer, int Id,string Question)
    {
        ViewBag.Question =Question;
        ans.Answer = PostyourAnswer;
        ans.CreatedDate = DateTime.Now;
        ans.ModifiedDate = DateTime.Now;
        ans.CreatedBy = 101;
        ans.ModifiedBy = 101;
        ans.FkQuestionID= Id;
        if (ModelState.IsValid)
        {
            new AnswerService().SaveOrUpdateAnswers(ans);
            var model = new AnswerService().GetAllAnswers();
            model = (from x in model
                     where x.QuestionID.Equals(Id)
                     select x).ToList();
            return View(model);
        }

        return View();
    }

But the problem is OnPost i get a null value inside the Question variable and hence i am not able to display the question on post when the user submits the form.
Please help me.I know i am missing sumthing silly..

  • 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-31T23:23:43+00:00Added an answer on May 31, 2026 at 11:23 pm

    try changing to

    @Html.ActionLink(item.Question, "Answer_Page","QuestionAnswer", new { @Id = item.QuestionID, @Question = item.Question },null)
    

    Now you should be able to get it in the Question variable.

    Personally i don’t think it is a good idea to pass the question as it is in the query string. Query string has a limit of characters i believe. you should ideally pass the question id only and build the question object again in your action method by querying your persistent data source.

    What is the maximum possible length of a query string?

    http://classicasp.aspfaq.com/forms/what-is-the-limit-on-querystring/get/url-parameters.html

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

Sidebar

Related Questions

I am developing my application using spring-web-mvc... Now at my Controller it returns like
I'm developing a web application using ASP.NET MVC 3 and Entity Framework Code First
I am developing MVC 3 application and its first time i am using subsonic.
I am right now developing a dead simple application using backbonejs mvc javascript library.Just
I am developing an MVC application using nHibernate; running through VS's built in web
I am currently developing an MVC application in ASP.net. I am using AJAX.ActionLink to
I am developing an application using Asp.net mvc and jquery. I'd like to use
I'm developing an application using ASP.NET 4 MVC 3. I'm using the default AspNetSqlMembershipProvider.
I'm developing a web application using ASP .NET MVC 1.0 and jQuery (including the
I am developing a ASP.NET MVC 3 application, i am using entity framework code

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.