@Matt - The action filter redirected to a virtual path, this is why I needed the method. I agree your approach is better as I only need to redirect, not get an actual virtual path, I was just curious why it didn't work. I dug a little deeper and found that when I used my approach from the controllers context it returns a valid virtual path (of the latter type) in actions that have at least one parameter, but returns null in actions with no parameters. So my approach fails at the controller level were it would be useful to get this information and to me this seems like a bug in MVC... To clarify:
In regards to this line: string q = this.BuildUrlFromExpression<FooController>(s => s.Detail(2));
calling it from *inside* a controller action with no params returns null, calling it from *inside* a controller action with one param returns the correct path. My filter that was not working was on a controller method that had no params, which I believe is why it broke.
Does this seem like a bug to you?
↧