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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:18:38+00:00 2026-06-03T08:18:38+00:00

My action is : [HttpPost] public ViewResult SearchPost(FormCollection frm) { IList <post> p =db.posts.Include(user).ToList();

  • 0

My action is :

[HttpPost]
public ViewResult SearchPost(FormCollection frm)
{

    IList <post> p =db.posts.Include("user").ToList();


    if (Request.Form["area"] != null)          
    {
        if ((p!=null) && (p.Any()))

        {

            p =p.Where(a=>a.area==Request.Form["area"]).ToList();     

        }
   }           
    if (Request.Form["floor"] != null)          
    {              
        if ((p!=null) && (p.Any()))

        {
            p = p.Where(a => a.floor ==   
           Request.Form["floor"]).ToList();                              
        }
    }            
    if (Request.Form["garage"] != null)          
    {
        if ((p!=null) && (p.Any()))

        {
            p = p.Where(a => a.garage ==   
            Request.Form["garage"]).ToList();                                    
        }
    }  


    return View(p);
}

it has shown no errors. but always return null. it should return filtered post objects or simply all posts without filtering. is there any problem ?? i can’t find it .

  • 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-06-03T08:18:40+00:00Added an answer on June 3, 2026 at 8:18 am

    I don’t know the full signatures of the types that you are dealing with, but perhaps try this code and see if you get any better results:

    [HttpPost]
    public ViewResult SearchPost(FormCollection frm)
    {
        var area = Request.Form["area"];
        var floor = Request.Form["floor"];
        var garage = Request.Form["garage"];
    
        return View(db.posts.Include("user")
            .Where(a => area == null || a.area == area)
            .Where(a => floor == null || a.floor == floor)
            .Where(a => garage == null || a.garage == garage).ToList());
    }
    

    (This is essentially a rewrite of your code down into a single query that might help you with debugging.)

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

Sidebar

Related Questions

my controller action: [HttpPost] public ActionResult AddPointAndCopyOtherSongToPlaylist(int id) { if (CheckIfAddPointToSelf(User.Identity.Name, id)) { var
In my fb application I calling a post action $.post(http://localhost:3435/Home/Try?id=123&x=1); My action [HttpPost] public
With the following simple action... [HttpPost] public PartialViewResult DoSomething(AnimalInfo animalInfo) { // animalInfo.AnimalKey SHOULD
This is what my controller action looks like [HttpPost] [OutputCache(Location = OutputCacheLocation.None)] public ActionResult
I have an HttpPost controller action that takes in a simple form DTO object.
I have an action : [HttpPost] public ActionResult MyAction(MyModel model) { ... if (model.MyCondition
Suppose you have the following controller action [HttpPost] public ActionResult Save( CustomerModel model )
I have a controller with action: [HttpPost] public ActionResult Add(Question container, HttpPostedFileBase file) {
I have this action method: [HttpPost] public ActionResult GetNextImage(int m_id) { ... return Json(new{...});
I have an action [HttpPost] public string Edit(Member member) and Member has a collection

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.