1

I have google and tried a lot of different solutions to this problem, non of them worked. this is as far as I got. I tried passing it with a Action Link and a anchor tag. Tried catching it from the url in the ActionResult. This anchor tag produce the right url

HTML

    <a class="link btn btn-default" ng-href="@Url.Action("CloseProject", "Home")?id={{item.ID}}">@Resource.CloseProjectButton</a>

C#

public ActionResult CloseProject()
    {
        Guid id = new Guid(Request["id"]);

            _fastaSamarbetenRepo.UpdatePropertyBagItemStatusToClosed(id);

        return RedirectToAction("Projekt");
    }

what am I doing wrong?

7
  • I suggest using HttpPost action for any code which updates data. Commented Aug 29, 2017 at 14:20
  • What specifically is your problem ? If your url is correctly generated what is missing ? Commented Aug 29, 2017 at 14:25
  • The url looks correct. But never hits the controller. I havent been able to debugg either. Which is really bad. I am having problems with the SharePoint debugger not attaching to the project. Commented Aug 29, 2017 at 14:32
  • when you click the link, what is happening ? Commented Aug 29, 2017 at 14:36
  • When I click the link the page refreshes as it should. That means it is passing thru the controller. The weird thing is that the status code is unchanged. I have a error notification system that filter the errors and shows it to the user in a user friendly manner. But it shows nothing. I really have to get the debugger working. Commented Aug 29, 2017 at 14:46

1 Answer 1

1

You should pass the parameter using new keyword.

@{
 var url = Url.Action("CloseProject", "Home", new { id = "{{item.ID}}"});
 url = HttpUtility.UrlDecode(url);
}

and use data-ng-href.

<a class="link btn btn-default" data-ng-href="@url">@Resource.CloseProjectButton</a>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanx. Got the debugger working for split second, it turns out the controller gets the GUID. The problem is elsewhere So Thank you sir!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.