uiCulture does not work on server - c#

I use ASP.NET, EF 6.0.2, MVC 5.1.1.
In web.config I set culture and uiCulture:
<system.web>
<globalization culture="de-CH" uiCulture="de" enableClientBasedCulture="false" />
</system.web>
When I run the application locally, then the validation messages are shown in German correctly.
When I publish the project to the webserver, the validation message are shown always in English.
But the printing of:
Culture: #System.Threading.Thread.CurrentThread.CurrentCulture.ToString()
UI Culture: #System.Threading.Thread.CurrentThread.CurrentUICulture.ToString()
shows correct the setted 'de-CH' and 'de'...
The validation takes place on the server instead (not client side). Because the validation message after submitting the form occurs
What I want, is to set the language of the application fix to German-Switzerland.

The problem was solved: The German language pack was not installed on the server.

Related

When I first start up website by clicking the link, it shows the error

enter image description here
I am fresher in ASP.Net C# (4.0). I developed one website and upload to a server. It works in my local system. But when i upload to the server, page displays one error in web.config. AND ERROR IS...
Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
Your detail is clear enough,To see what caused this error add codes below to your webconfig inside configuration section and then try again
<system.web>
<customErrors mode="Off"/>
</system.web>

Set a different language for ASP.NET MVC errors

I have an ASP.NET MVC application configured for Portuguese, on Visual Studio 2015. While debugging this application, I've set <customErrors mode="Off" />, but all errors are shown in Portuguese, and I want to see them in English.
I tried to set this in Web.config:
<globalization uiCulture="en-US" culture="en-US" enableClientBasedCulture="true" />
In Global.asax I tried:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
and
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
I also uninstalled the Nuget package Microsoft.AspNet.Mvc.pt-br, no success.
This question is similar, but I need a solution that doesn't involve changing the machine's configuration or installed components, as that's not allowed in my workplace.
How can I make all error messages show in a specific language (in this case, English)?
Today when I tried this again, to my surprise the messages were in English (almost, see below). I tried to reproduce the error I had yesterday, but I couldn't.
Perhaps it is just a matter of restarting (VS or the PC). I also kept working on the project at night on a different PC, but not on anything related with this issue, so I can't say it made a difference. All I have set up in Web.config is:
<globalization uiCulture="en-US" culture="en-US" enableClientBasedCulture="true" />
But still not everything was in English. While trying to reproduce the error, I forced a library load error, I used a DLL that requires Ninject to be installed. The error message was (emphasis mine on the translated part):
Server Error in '/' Application.
Could not load file or assembly 'Ninject, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7' or one of its dependencies. O sistema não pode encontrar o arquivo especificado.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
That part was supposed to be: The system cannot find the file specified.
In that case, I don't think there is much that can be done programmatically only.
Uninstall the .net framework in the portugese version and reinstall the english version, that should do the trick.

launching a web service (.asmx) in a IIS 6.0

I have developed a web service with the .asmx extension using C# and i want to deploy this into my VPS which has Windows Server 2003 with IIS 6.
Service is running with Framework 4.0 and it's installed in the VPS also. When I upload the precompiled version into the VPS it shows a runtime error
Server Error in '/' Application.
Runtime Error
Description: An application error
occurred on the server. The current
custom error settings for this
application prevent the details of the
application error from being viewed
remotely (for security reasons). It
could, however, be viewed by browsers
running on the local server machine.
Details: To enable the details of this
specific error message to be viewable
on remote machines, please create a
<customErrors> tag within a
"web.config" configuration file
located in the root directory of the
current web application. This
tag should then have
its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are
seeing can be replaced by a custom
error page by modifying the
"defaultRedirect" attribute of the
application's <customErrors>
configuration tag to point to a custom
error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
can anyone help me on this?
Update
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to >service this request. Please review the specific error details below and modify your >configuration file appropriately.
Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names >are case-sensitive.
Source Error:
Line 26:
Line 27:
Line 28:
Line 29:
Line 30: Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Source File: C:\Inetpub\vhosts\akashvahini.com\httpdocs\web.config
Line: 28
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET >Version:2.0.50727.3053
this is the new error message after enabling debugging in the web.config
You should enable debugging to diagnose the problem.
Microsoft has a very detailed explanation on how to enable detailed debugging over here.
Server Error in '/' Application.
That error is too generic, check the output after you enabled debugging and post the results.
And don't forget to disable debugging after your site goes live.
Update:
Seems to be permission related:
http://forums.iis.net/p/1042369/1454379.aspx
The ASPNET user account needs permissions for the folder that contains your asmx service.
Update2:
You can give the ASPNET user permissions using the file system permission dialog:
http://www.asp.net/learn/whitepapers/denied-access-to-iis-directories
Might look different on newer versions of Windows.
From my experience "Server Application Unavailable" means that you have got web sites that use different versions of .net in the same application pool.
the site that hosts your webservice needs to be in an app pool that only has .net 4.0 web sites. The application pool is configured on the Home Directory tab in the web site properties.
Looks to me like the application pool is trying to run two difference versions on .net.
Make a new application pool and call it something like .Net4 and then move the new site across to use this app pool and everything should work.
This error is shown by
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET >Version:2.0.50727.3053
Where the site with a .asmx should say .Microsoft .NET Framework Version:4.0 etc...

Not able to load MicrosoftAjax.debug.js

I have an ASP.NET 3.5 web application which works perfectly fine on my local machine and when I deploy it on my Windows 2008 server. I am getting the following javascript error:
Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
Line: 4723
Char: 21
Code: 0
URI: http://localhost/ScriptResource.axd?d=e1Gld4LGHLsC4rWqevEI8zAMJKoVcCEVHBjdJIxcQLO9of6t7nNopbI1YyxJTv1QbaxN_lTSoz5Ly-VjBRHp08Mf3xxg5V9i5Z0AiXIkZRY1&t=6af1de90
I have a utility which can decrypt the URI and tell exactly what file is missing and it tunrns out that the file is ZSystem.Web.Extensions,3.5.0.0,,31bf3856ad364e35|MicrosoftAjax.debug.js|. Why am I not able to load this js file? Any help?
Possible options:
You've not installed .NET Framework SP1 on your server, so it can't find the 3.5 assemblies to generate the MsAjax file.
You've deployed your web.config file with <compilation debug="true"> while IIS has been configured to compile it in release mode.
I have run into a similar problem before when the development and production machines are set for two different time zones. When ASP.NET AJAX tries to load a script resource from an assembly, the last modified date/time of the assembly is validated. If the local time of the production server is "earlier" than the last modified date/time of the assembly, then an ArgumentOutOfRange exception is generated by ASP.NET AJAX when processing the request.
Really difficult to debug since the problem eventually resolves itself.
I suppose this might be possible with a System assembly if Copy-Local is set to true.
I was using some third party web services and the problem was with the following xml tag in the web.config:
<extendedProtectionPolicy policyEnforcement="Never" />
Once I removed this tag the error went away

Problem with getting custom errors to display on IIS7

We're running a site built in EPiServer (CMS5 R2, latest version) and ASP.NET 3.5 that's running on IIS7, we've built a custom error handler that utilizes the URLRewriter-functionality of EPiServer to handle 404 and 301 status codes, everything works locally (Windows 7 + IIS7.5) but we just can not get the 404 pages to work on the live server (Windows 2008 Server + IIS7). The 301-redirects work but for the 404-page we just get the default IIS7 message:
iis7 default 404 message http://episerversucks.com/upload/iis7_error.png
The handler is obviously getting fired since the pre-defined 301-redirects work (URLs from an old site that we need to redirect to the new site), but for the 404 IIS7 just replaces them with it's default message.
The 404 handler works in such a way that is does an internal redirect to a page /Pages/Error404.aspx that display a nice customized 404-page in an appropriate language and sets it's own status code to 404 through Response.StatusCode = 404; I got the tip from a site to change TrySkipIisCustomErrors variable to true, i.e. Response.TrySkipIisCustomErrors = true;but that didn't help either.
The only configuration difference I've found between the local dev machines and the server is that the local machines have a configuration setting called ".NET Error Pages" and a setting called just "Error Pages", while the live server only has the setting called "Error Pages" and is missing the .NET Error pages ones, but I've found no way to add the .NET Error Pages config dialog to the server, is it IIS7.5 specific?
I've been digging my way through this for the better part of a day and just can not find a solution that seems to work, so I turn here.
Edit: The local dev version and the live version have identical web.config's, settings, etc. (except for the database connection string obviously)
Ok so I solved it, the problem was setting the errorMode to "Detailed."
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
If it's on Custom the IIS7-error handler intercepts all pages that return 404 and switches the response out.

Categories

Resources