0

Our webform (ProcessStudent.aspx) is designed to receive three parameters in the QueryString: Name, Grade, Class. Page_Load retrieves these three parameters and sends it to a method SaveStudent (ie. SaveStudent(name, grade, class);).

I need to process several three-parameter combinations for one page. I basically copied/pasted ProcessStudent.aspx, but I need to modify the way I read the parameters. I can change the URL structure, but everything else needs to stay the same.

So my initial thought was to include these combinations in the URL; for example, each value would be separated by a char and each combination by another char. Something like this, which I would then parse :

ProcessStudent.aspx?Students=Joe|5|Science,Bob|6|Math,Mary|5|English

Would something like this work? Is there a better way?

halfer
  • 19,824
  • 17
  • 99
  • 186
fdkgfosfskjdlsjdlkfsf
  • 3,165
  • 2
  • 43
  • 110

2 Answers2

1

Yes it would work. As far as better... You could post a json string, which would be much cleaner. I personally would use a rest service with just JSON(or XML if you like).

Hope this helps.

Trey
  • 413
  • 4
  • 12
  • Thanks for the comment. Since the webform works with input via the URL, would you have a link that would show me how to post the data without having to make major changes to the webform? – fdkgfosfskjdlsjdlkfsf Nov 29 '16 at 16:10
  • Well this is close to what I had pictured: – Trey Nov 29 '16 at 16:19
  • http://stackoverflow.com/questions/26541801/how-to-send-json-data-in-url-as-request-parameters-in-java – Trey Nov 29 '16 at 16:19
1

The thing you'll need to watch out for is that the query string has a length limit in some browsers (https://stackoverflow.com/a/812962/97382) so depending how many you mean by "several" and which browser(s) you're using you could run into those limitations.

You would be better off to POST the data as you do not run into the size limitations.

Community
  • 1
  • 1
Craig W.
  • 17,838
  • 6
  • 49
  • 82
  • Thanks for the comment. Since the webform works with input via the URL, would you have a link that would show me how to post the data without having to make major changes to the webform? – fdkgfosfskjdlsjdlkfsf Nov 29 '16 at 16:10
  • I don't have one handy but I'm sure if you google something like "asp.net webform post" you'll find lots of options. – Craig W. Nov 29 '16 at 16:29
  • Also the convention is to use POST to create new records as GET is supposed to be idempotent. – Dour High Arch Nov 29 '16 at 18:46