0

What am I doing wrong here please? I get a NullReferenceException.

string outUrl = "http://whatever.com";
HttpContext context = HttpContext.Current;
context.Response.Redirect(outUrl, false);

When I use new like this:

HttpContext HC = new HttpContext();

I get No Overload for method. I am working with .NET 2 inside VSTA.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Sean
  • 163
  • 1
  • 2
  • 11

1 Answers1

0

HttpContext is not possible to instanciate and will only be created by your application.

It even really hard to mock (create a fake), Why do you need one ? what is your application type ?

Kuqd
  • 497
  • 3
  • 8
  • In short, I need to mix rules and code with an InfoPath form. I want to redirect the user to a webpage after they have clicked on the submit button. I would also be fine with closing the form programatically, but that's also a challenge. – Sean May 30 '12 at 13:35
  • I ended up doing this in a different way with conditional formatting in InfoPath. Thanks for the answer. I didn't want to chase an empty solution. – Sean May 31 '12 at 14:50
  • I think you did well, it was just impossible. – Kuqd May 31 '12 at 15:20
  • I never added any detail here so: instead of redirecting, I added a section (with rules) saying thanks for submitting that would become the only visible element on the page once the form was submitted. – Sean Oct 25 '12 at 14:59