Custom Resource Provider - localization

I am using custom resource provider in Asp.Net to get the data from the external resource files, After changing the browser language it does not select the proper translation. i.e. It always returns English version. On the other side, if i use Asp.Net tag
It returns the correct translation. I configured it in web.config
Am i missing something?

Actually i figured out by myself. In my custom resouce provider, i was passing the cultureinfo by myself. I change it to null and it started working. Its wiered but worked for me.

Related

Umbraco URL issue with Vorto

I am using vorto plugin in my Umbraco 7 application to achieve the multilingual capability.
I mentioned the URL in hostname as 'localhost/clientname/en'.
Whenever I open login page the URL which is getting form is 'http://localhost/clientname/en/login'.
This is the structure of vorto URL writing.
But can I achieve it like 'http://localhost/clientname/login/en' ???
I want language names at the end of the URL, not in between.
Is it possible ?
Please help....i am badly stuck in my project task !
It sounds like you need a custom URL provider, setting the domain to 'localhost/clientname/en' will mean that the URLs will always get added AFTER the language part as the host is always the first part of the URL.
Have a look at this article on URL providers and content finders: https://24days.in/umbraco-cms/2014/urlprovider-and-contentfinder/ it's quite old, but it should still work. That should give you an idea of how to make it work. Basically you want the URL provider to append the language to the end of the URL, and the content finder to strip the language from the end and then find the actual content. You can also then set the language of the current thread in the content finder so that Vorto and Umbraco are using the correct language based on the URL.

Sitecore gives a blank page with just the text "Default page" in my MVC solution

When I browse to my startpage, e.g. /sv I get a blank page that just says "Default Page". However when I try /sv/ it works. Subpages like /sv/example work without slash though. I'm using Sitecore 7.1 with only MVC views.
Remove the default.aspx file from the web root.
That will fix your problem.
When requesting URLs without a slash at the end, the "StripLanguage" processor of the preprocessRequest pipeline rewrites path to the value of the Settings.DefaultPageName setting ("default.aspx" by default). Since such page physically exists on your site, ASP.NET MVC routing system does not handle such request, and the file itself is served. This behavior is controlled over the RouteCollection.RouteExistingFiles property (false by default), please refer to the following article for the details:
http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.routeexistingfiles.aspx.
In other case, when a slash is added after a language, this won't happen, since the "StripLanguage" processor does not rewrite the path (which is also not an expected behavior). As a result, request URL does not match the "default.aspx" static file in the site and request is getting processed by ASP.NET MVC.
I suggest you to add the following setting to the "Web.config" file (instead of creating a "default.aspx" page), which points to the "default" page without extension:
<settings>
<setting name="DefaultAspxPageName" value="default"/>
</settings>
After that, the /default URL, without ".aspx" extension, will be processed by MVC and the appropriate item will be rendered independently of a slash after the language URL section.
On my side it works.
I want to point out that the answer to this is not my own but given from the support over at Sitecore who I want to extend a big "Thank you!" to. I had googled this forever until they helped me and I thought that I want to have this document and easily found when others struggle with it. A bug is filed and they are working on fixing it.
DefaultAspxPageName is Hidden Setting.. We can find more such hidden settings..#
http://www.newguid.net/sitecore/2014/sitecore-hidden-string-configuration-settings/

ASP.NET MVC Determine mime type by file/file path

I am using ASP.NET MVC 3.
The application is targeting .net 4.0.
I was trying to pass a virtual path as argument to my controller's action and return the file without reviewing the actual physical path on the server and providing basic Authorization. Unfortunately I was unable to find a suitable overload for File method to generate the appropriate ActionResult. I am stuck at determining mime type for the file.
I've found a couple of solutions for determining mime-types by file name, but none of them are satisfying me. I was wondering how does IIS determines the mime type when you are requesting a file on the server? Is it possible to somehow pass to IIS the responsibility for determining the mime type for the response
If you are using .net 4.5 there is a function now that takes a filename and returns a mimetype:
MimeMapping.GetMimeMapping(filename)
http://msdn.microsoft.com/en-us/library/system.web.mimemapping.getmimemapping.aspx
Take a look at the function later in this question:
How to use Generic Handlers (ASHX) in ASP.NET MVC?
It is a little out of date with the list of file types now but it's a start, will try to find my more recent one.

IIS 7 and ASP MVC issue with period in query string

I have an issue where I am sending over an email address to be validated against (make sure its not already used and is a valid email address). Now it worked fine on Cassini, but now I am using IIS7 it refuses to map the route.
The Url would look like:
http://localhost:23456/is/email/taken/test%40test.com
I have turned the route debugger on to make sure there is no problem with the route, and if I remove the ".com" bit at the end it works fine and the route matches (although its not a valid email address so is invalid). However if I leave the .com or whatever .extension is used, the route debugger doesnt even display so it makes me think IIS isnt even directing the traffic to ASP and is looking for a static file.
Has anyone else had this before? and if so how do you solve it?
OK, IIS may be treating that as a file with an extension that is blocked or mapped to a handler that is not MVC. It first checks to see if there is a physical file on disk so some of the handling of the URL isn't all MVC engine only. Do you have configurations that are protecting/refusing some extensions?

Spring MVC: url passing variable page style not working

I am using spring mvc for my app. So far everything is going all. However, when I get to a page that has a variable in the url (ie, /edit/{id}), the style doesn't work on that page. In addition when I submit the form on that custom path page and try to go to another page (from the controller using the ModelAndView), the style doesn't work on that destination page which is weird cause the style works fine on that when I access it from elsewhere.
I think the reason the style is not working on the destination page is because the url still stay at the custom path with the url passing variable (localhost:8080/app/edit/5).
Late answer, but I've just experienced this myself and am having a few issues. As far as style sheets or JS files (basically any static resource) not being found after using a path variable, I was able to fix that by prefixing all of my style sheet or JS file links with ${pageContext.request.contextPath}. This ensures that the server always searches for them from WebContent, rather than from the offending path variable. I am also now having the issue of not being able to send proper requests to the other pages, but as my controllers only return Strings for the view resolver rather than ModelAndView objects, I'm not sure your solution will fit for me.

Resources