Frage

I'm almost there with this loop!

Controller:

// Hide 'posts'
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Hide (int id)
    {
        var post = db.tb_SH_Forum_Posts.Single(p => p.Post_ID == id);
        post.Private_ID = (post.Private_ID == 1) ? 2 : 1;
        db.SaveChanges();
        RedirectToAction("Details", new { id = post.Thread_ID });
    }

View:

@foreach
(var post in Model.tb_SH_Forum_Posts.Where(w => w.Private_ID == 1).OrderBy(o =>     o.Post_Date))
{
using (Html.BeginForm("Hide", "Post", new { id = post.Post_ID }))
{   
   <input type="submit" name = "hidePosts" value="Hide" /> 
}

<div class ="post">
<fieldset>
        <p class="post_details">At @post.Post_Date By @(post.Anon == true ? "Anonymous"     : post.Username)          
        </p>
        @post.Post_Desc

</fieldset>
        </div>}

Error:

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Post/Hide/1

I know that /Post/Hide/1 doesn't exist! I don't want it to! It's supposed to redirect to /Thread/Details/id (ergo the 'thread' that the 'post' was in)

As always, any help/guidance is MUCH appreciated!

War es hilfreich?

Lösung

 return RedirectToAction("Details", new { id = post.Thread_ID })
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top