views:

313

answers:

1

This piece of code used to work in MVC 1 but it does not since I upgraded to MVC 2:

    <%=Html.ActionLink(Resources.Localize.Routes_WidgetsCreate, "Create" + "?modal=true", "Widget", null,
                                      new
                                        {
                                            rel = "shadowbox;height=600;width=700",
                                            title = Resources.Localize.Routes_WidgetsCreate
                                        })%>

I am aware it has something to do with the way that new ActionLink helper encodes things, so the result that comes out is something like this:

"http://localhost:53704/Widget/Create%3fmodal%3dtrue"

The problem is, when clicked, the Shadowbox modal opens up and inside, where the request View should be rendered is this exception:

Server Error in '/' Application.

A potentially dangerous Request.Path value was detected from the client (?).

What can I do to get past that? Do you recommend another way of sending params to the view besides in QueryString (in this case I need "modal" because in the view I select CSS styles based on whether we are rendering modal or not)?

+3  A: 

You should not build query string parameters this way in MVC one, either. Instead, add them as Route value tokens:

<%=Html.ActionLink(Resources.Localize.Routes_WidgetsCreate, "Create",                       "Widget", 
                                  new
                                  {
                                      modal = true
                                  },
                                  new
                                    {
                                        rel = "shadowbox;height=600;width=700",
                                        title = Resources.Localize.Routes_WidgetsCreate
                                    })%>

Anything which does not match an identifier in the route itself will be appended as a query string parameter.

Craig Stuntz
Interestingly enough, while it works, I now get a dialog box saying:"This page is accessing information that is not under its control This poses a security risk. Do you want to continue? Yes/No"this is all happening at localhost, so I don't get it??
mare
Actually this has nothing to do with modal but with the View itself cause it also happens if I directly browse to the URL.
mare