1

I have a RenderPartial that yellow screens IE at this line

int addLocations = Model.Options.OfType<myOrderRowOption>().Single().AdditionalLocationsCount;

error is: Exception Details: System.InvalidOperationException: Sequence contains no elements

FireFox renders it fine. How can a server-side error be influenced by which browser is being addressed? (this isn't a postback - it's happening on the first-time call to the view).

Followup:

Ok...so i cleaned up the code to make it a little more presentable and the error condition no longer existed. The basic gist of the PartialView is populating a form where the orderRow can hold 2 different types of inputs - a radio button group and possibly a textbox.

Originally i had 2 separate FOREACH loops to iterate thru all option and wrote out the radio buttons in the first and the textbox in the 2nd. (with a 'If OptionType' test inside each loop.

I changed that to 1 FOREACH loop and used the ELSE branch instead. That cleared the error condition but I'm still not seeing how server-side conditions could be influenced by the browser in a non-postback condition.

this code structure works - comments below detail the differences from the original error condition.

<div class="showOrderRow">
    <%string isChecked = "";
      foreach (var option in WebinarFacade.Instance.GetOptions(Model.Webinar))
      {

          isChecked = (int)Model.RegistrationType == option.ID ? "checked" : "";


          var optionType = option.GetType();
          if (optionType.Name == "Option")
          {%>
    <input type="radio" ... />
    <%
       } 

// originally this foreach loop ended and a started
//a 2nd one with a test that would exlcude the radio buttons
//if (optionType.Name != "Option")
       else
       {//point of original error
       int addLocations = Model.Options.OfType<myOrderRowOption>().Single().optionCount;
    %>
    <br />
        <h5>
            Additional Locations</h5>
            <input type="text" value="<%=addLocations%>" );'
                name="Count<%=Model.Order.ID %>" 
    <%
       }
 }
</div>
justSteve
  • 5,444
  • 19
  • 72
  • 137
  • It all depends on how you identify which items to get and how you build them. You might want to show that code instead. – jgauffin Jan 23 '11 at 17:11
  • I wouldn't have thought to clear cache in that i expect a clean separation between server-side problems and client-side. – justSteve Jan 23 '11 at 18:07
  • I have a comment similar to jgauffin... that error seems to be resulting from how the Model is loaded, which is in your controller code. You should post that code too. – Jason Capriotti Jan 23 '11 at 18:56
  • If you fixed this yourself, you should post how/why as an Answer, then mark it as Answered. – Jon Adams Feb 21 '11 at 16:42
  • IE and FireFox might be sending requests different from each other or one browser might be sending more requests than the other (e.g. for icons or other cacheable resources.) You could use something like Fiddler to see what each browser is sending to the server. That might help you discover why the request from one browser blows up but not from the other browser. – Hector Correa Mar 03 '11 at 13:59

0 Answers0