locked
Performance Question on Localization – Code Behind or ASP Markup? RRS feed

  • Question

  • User-516386598 posted

    Hello –

    I am building a web application using ASP.NET 4.0; this web site/application needs to be localized to display in multiple languages.  At this point, I am using Global resource files for two reasons …

    First, many strings (not all, but 80-90% or so) are used across more than one page and will be used in reports.

    Second, I love the “strongly-typed” benefit of the global resources which makes it so much easier to code.  But, I believe the strongly-typed feature only applies in the code behind, not in the ASP markup.

    Question:  Does populating the string values for a page in the code-behind file (using the Page_Load event) cause a significant performance (speed) hit compared to populating the string values through the ASP markup?

    I’m just starting with this; I have localized one page using code-behind to populate the page’s string values in the Page_Load event with multiple lines like so:

    lblPrintInvoice.Text = Resources.Base.Print__Invoices.ToString

    This is working fine, I just want to make sure this is the best approach and doesn’t cause a noticeable performance hit compared to the alternative method of populating strings from the ASP markup.

    Thanks for any input you can provide!

    Wednesday, April 20, 2011 10:42 PM

Answers

  • User-1856974186 posted

    This is probably what ASP.NET does underneath; or something similar at least. When it loads the page it has to iterate the controls and load the resource strings, so the perf difference is probably not going to be noticable. But I'd check to be sure; create a test page and try it out.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 21, 2011 4:29 AM

All replies

  • User-1856974186 posted

    This is probably what ASP.NET does underneath; or something similar at least. When it loads the page it has to iterate the controls and load the resource strings, so the perf difference is probably not going to be noticable. But I'd check to be sure; create a test page and try it out.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 21, 2011 4:29 AM
  • User-516386598 posted

    Hi Dave -

    Thanks very much for the response!

    When you say "this is probably what ASP.NET does underneath", I assume you mean server-side?

    I have tried a couple of pages using both approaches and I can't tell a difference, but they're pretty simple pages. I figured I'd put the question out there and if there was an obvious performance difference known in the development community, people would jump in and say so.

    I plan to move forward with the strongly-typed, code-behind approach ... if I run into anything I'll post back here for future reference.

    Thanks again!

    Friday, April 22, 2011 12:40 AM
  • User-1856974186 posted

    Yes, server-side, as it builds the page.

    Saturday, April 23, 2011 6:29 AM