Comments (14)
v2 knows nothing about MVC and controllers etc., although I think you are right in that the URL localizer assumes that the 'root' of the web app is at the 'host' portion of the URL. Would you provide some examples of expected behaviour vs. observed behaviour. Thanks.
From: Raul Vejar [mailto:[email protected]]
Sent: 08 May 2013 16:05
To: danielcrenna/i18n
Subject: [SPAM] [i18n] Root of website when using virtual folder cannot be found (#60)
When using a virtual folder configuration and the default early url localizer, for example 'localhost/MyApp/' there is a problem when trying to access the root. The error seems to indicate it's trying to find 'MyApp' as a controller when it should acknowledge that from the routing table that parameter is implicit for the default route.
—
Reply to this email directly or view it on GitHub #60 .Image removed by sender.
from i18n.
i18n configuration:
i18n.LocalizedApplication.Current.DefaultLanguage = "en";
i18n.LocalizedApplication.Current.PermanentRedirects = true;
//i18n.LocalizedApplication.Current.EarlyUrlLocalizerService = null;
i18n.UrlLocalizer.UrlLocalizationScheme = i18n.UrlLocalizationScheme.Scheme2;
i18n.UrlLocalizer.IncomingUrlFilters += delegate(Uri url)
{
if (url.LocalPath.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase))
return false;
return true;
};
Application virtual path: "localhost/MySite"
Mapping rules include a default one that has a default controller Home and a default action Index, as standard
When typing in "localhost/MySite" I would expect to get the Index action of the Home controller, instead I get a 404
This only happens when the module is in web config, if you comment out the line for the i18n module, the page is routed correctly
from i18n.
- Which URL is not found? That is, what is showing in the browser address bar when you get 404? Has a redirect occurred?
- What happens when you request an explicitly localized URL such as localhost/MySite/en and localhost/en/MySite ?
from i18n.
- No redirects have occuredd, the Requested Url says 'MySite'
- When using localhost/MySite/en the same result. When using localhost/en/MySite I get a handled 404 (as opposed to a resource not found 404 as the others)
from i18n.
"When using a virtual folder configuration ... for example 'localhost/MyApp/'"
Okay, I'm not 100% clear what you mean by this. Would you elaborate please. Are you referring to an IIS config or MVC area ...?
from i18n.
It's an IIS configuration where the application is located inside a folder within an application.
If you don't feel like configuring your local IIS you can also do the same with IIS Express although it is a bit trickier, follow the instructions:
Right click on the project and select properties, select the 'web' tab, then under 'Servers' select 'Use Local IIS Web server' and check the 'User IIS Express' box. Inside the project url add a folder name to the end of the url.
After that is done if you try to run the project it will complain about things in the web.config being defined twice that's because IIS express defines both a binding for the root of the url and for the virtual folder to the same project. To fix this go to your documents folder, you will find an 'IISExpress' folder, inside there should be a config folder with an 'applicationhost.config'. Open that and search for the url you typed in for your project. You will see a site xml tag with 2 application tabs inside, one for the root of your url and another for the virtual folder. In the one for the root of the url ("/") change the physucalPath to a folder you know is empty (ie: C:\TEMP).
That should do it, restart IISExpress and run the project and it should work (or in this case throw the 404 for the root path if the i18n module is in the web.config).
from i18n.
Can you send me your complete element and I'll try and reproduce that here. What you describe is what I already have.
From: Raul Vejar [mailto:[email protected]]
Sent: 09 May 2013 14:39
To: danielcrenna/i18n
Cc: Martin Connell
Subject: Re: [i18n] Root of website when using virtual folder cannot be found (#60)
It's an IIS configuration where the application is located inside a folder within an application.
If you don't feel like configuring your local IIS you can also do the same with IIS Express although it is a bit trickier, follow the instructions:
Right click on the project and select properties, select the 'web' tab, then under 'Servers' select 'Use Local IIS Web server' and check the 'User IIS Express' box. Inside the project url add a folder name to the end of the url.
After that is done if you try to run the project it will complain about things in the web.config being defined twice that's because IIS express defines both a binding for the root of the url and for the virtual folder to the same project. To fix this go to your documents folder, you will find an 'IISExpress' folder, inside there should be a config folder with an 'applicationhost.config'. Open that and search for the url you typed in for your project. You will see a site xml tag with 2 application tabs inside, one for the root of your url and another for the virtual folder. In the one for the root of the url ("/") change the physucalPath to a folder you know is empty (ie: C:\TEMP).
That should do it, restart IISExpress and run the project and it should work (or in this case throw the 404 for the root path if the i18n module is in the web.config).
—
Reply to this email directly or view it on GitHub #60 (comment) .Image removed by sender.
from i18n.
<site name="Growler.Web(1)" id="31">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\TEMP\New folder" />
</application>
<application path="/Growler.Web" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\VisualStudioProjects\2012\Trunk\Growler.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:60138:localhost" />
</bindings>
</site>
from i18n.
I've hopefully pushed a fix for this.
There is a new global setting as follows:
i18n.LocalizedApplication.Current.SiteRootPath = "/MySite";
Let me know how you get on.
From: Raul Vejar [mailto:[email protected]]
Sent: 09 May 2013 14:56
To: danielcrenna/i18n
Cc: Martin Connell
Subject: [SPAM] Re: [i18n] Root of website when using virtual folder cannot be found (#60)
<site name="Growler.Web(1)" id="31">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\TEMP\New folder" />
</application>
<application path="/Growler.Web" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\VisualStudioProjects\2012\Trunk\Growler.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:60138:localhost" />
</bindings>
</site>
—
Reply to this email directly or view it on GitHub #60 (comment) .Image removed by sender.
from i18n.
I'll try it out, but it should be able to pull the root path from the context, let me try to see if I can get it working now that you've added the hook I didn't know where to put
from i18n.
It seems to work for the url without a trailing '/' (ie: 'localhost/MySite') but it gives the same error when the url has a trailing '/' (ie: localhost/MySite/')
from i18n.
I can't reproduce this. Would you try again with latest updates and confirm whether it still fails?
Also, note that I've had to replace all calls in my code to
`````` i18n.LanguageTag.SetLangTagInUrlPath```
with calls to
LocalizedApplication.Current.UrlLocalizerForApp.SetLangTagInUrlPath
to ensure this works with non-root application paths.
For instance, this is what my SetLanguage action looks like now:
```
[AllowAnonymous]
public ActionResult SetLanguage(string langtag, string returnUrl)
{
DebugHelpers.WriteLine("AccountController::SetLanguage -- GET -- langtag: {0}, returnUrl:{1}",
langtag,
returnUrl);
// If valid 'langtag' passed.
i18n.LanguageTag lt = i18n.LanguageTag.GetCachedInstance(langtag);
if (lt.IsValid()) {
// Set persistent cookie in the client to remember the language choice.
Response.Cookies.Add(new HttpCookie("i18n.langtag")
{
Value = lt.ToString(),
HttpOnly = true,
Expires = DateTime.UtcNow.AddYears(1)
});
}
// Owise...delete any 'language' cookie in the client.
else {
Response.Cookies["i18n.langtag"].FlagForRemoval(); }
// Patch in the new langtag into any return URL.
if (returnUrl.IsSet()) {
returnUrl = LocalizedApplication.Current.UrlLocalizerForApp.SetLangTagInUrlPath(returnUrl, UriKind.RelativeOrAbsolute, lt == null ? null : lt.ToString()).ToString(); }
// Redirect user agent as approp.
return this.RedirectWithSubSite(returnUrl);
}
```
```
```
from i18n.
Let me check this with the latest code
from i18n.
Confirmed, works fine with latest version
Thanks
from i18n.
Related Issues (20)
- could not translate when using combine string (javascript) HOT 4
- After using PostBuild.exe, my translations stay between exclamations HOT 1
- null check missing for httpcontext.response.contenttype HOT 1
- HTML markup in a formatted string displays as text HOT 1
- Javascript localization in MVC 5 project HOT 2
- Contribution support HOT 1
- Translate Password error messages? HOT 4
- Problem when displaying Spanish "ñ" character HOT 5
- Http Custom errors no longer work when i18n.LocalizingModule is added to modules HOT 5
- Javascript localization not working because browser cache HOT 1
- Arabic and French translation doesn't get replaces in javascript files
- where is i18n.LanguageHelpers.ParseAndTranslate? HOT 3
- Announcing release 2.1.16 HOT 1
- only every other nugget in messages.po is being translated HOT 4
- 2.1.16 doesn't translate some items HOT 4
- Announcing release 2.1.17
- vb.net issues HOT 4
- problem with axd file
- Issues with rendering special character inside i18n translation jQuery Rails HOT 2
- .net 8 Compatible HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n.