2013-06-17 20 views
8

Tôi đã đoạn mã sau:querystrings Đi qua để RedirectToRouteResult (bên cạnh điều khiển và hành động)

var routeDictionary = new RouteValueDictionary {{"action", "Login"}, {"controller", "Persons"}}; 
filterContext.Result = new RedirectToRouteResult(routeDictionary); 

Điều đó sẽ tạo ra "/Persons/Login"

Làm thế nào tôi có thể vượt qua một chuỗi truy vấn aditional vào mã trước đó? do đó nó tạo ra "/Persons/Login/?someQuerystring=someValue"

Trả lời

25

Hãy thử điều này:

filterContext.Result = new RedirectToRouteResult(
    new RouteValueDictionary { 
     { "action", "login" }, 
     { "controller", "persons" }, 
     { "someQuerystring", "someValue" } 
    } 
); 
+0

Cảm ơn, nó làm việc. – sports

Các vấn đề liên quan