Acumatica: How to get current localization - asp.net

I have another site will be called from acumatica. I want when i call a site, i will pass current localization via url.
As title, i want to get current localization after login.
Please help me.
Thanks so much

I have found a answer, i viewed a login.aspx.cs and i saw the cookie store culture.
Cookies["Locale"]["Culture"]

You may also want to check
PXLocalesProvider.GetCurrentLocale()
as one must avoid bypassing the framework.

Related

Silverstripe URL Mapping

I'm trying to understand how URL Mapping works. I've gone through numerous pages, but I can't seem to wrap my head around what I'm trying to do.
Its really simple, I use DataObjects as pages approach and I have a member extension written to the member class. And I have the typical actions, show, edit, add.
So if I go to www.mywebsite.com/members/show/1 I can see the first user. If I change show to edit, I can edit the first user. Now if I go to www.mywebsite.com/members/add I can create a new user. This is working all as expected due to the functionality I created in the add method.
My problem is in the fact that when you go any website, you don't register to the website by going to members/add, you register by going to website.com/Register or something similar. From code management perspective, it is a lot easier for me to leave the code the way it is now. I don't want to have to create a Register page and move the code there, instead I am trying to figure out if it is possible to go to www.mywebsite.com/Register and have it load www.mywebsite.com/members/add. I am not talking about a redirect link that would update the url, I want users to still see Register in the url and not see /members/add.
Vice versa, if users were to go to www.mywebsite.com/members/add I want the link to update to Register or say page not found.
Is this possible with Silverstripe Framework?
I am not 100% sure, but I believe this is called URL Masking.
This is very possible, firstly I'd advise that you look over...
silverstripe-memberprofiles
...because even if you dont' want to use an existing module I'm sure there would be useful information. There is a great example of "pure" routing (i.e. silverstripe no cms) that leads on to "nested" routes - which is what I think you are asking for, so I highly recommend reading the slides below and then the created todo app
silverstripe-framework-building-without-the-cms
todo app source

Best way for ASP.NET MVC5 localization where locale is passed in querystring with attribute routing

A very long title, sorry for that.
I'm looking for your input on the best way to support localization in an ASP.NET MVC 5 project in which i would like to pass the locale as part of the querystring. This way it would be easy for users to share a link to website and also pass the correct locale as part of the link.
If this would be done using, for example cookies, the user would pass a link but the page might be in a different language for the person who receives the link. I don't think that that is very nice.
The solution i currently use (http://afana.me/post/aspnet-mvc-internationalization.aspx) does not work nice with incorrect urls and just keeps loading the same page in loop. There is a lot of information on the web and i already went through a lot but i would like to know what is most commonly used and really works well.
As a bonus i would like the solution to work with attribute routing as my current solution doens't play nice :(
you can use resource files for that, the current culture is in the current thread of the web request, so no need to pass it in the querystring but it can be done;
have a look at this live demo: http://prodinner.aspnetawesome.com
you can download/read pdf about it here: http://prodinner.codeplex.com
you can see there that you can change the language using the dropdown;
in Global.asax.cs Application_BeginRequest, there's already code in there related to language, it reads a cookie now (or it's absence), you can make it read the querystring

Globalization of controller names and actions

Is it possible to create "aliases" of my controllers and actions, instead of adding one more item to the URL to indicate the language?
Example:
For English:
/controllerNameInEnglish/actionNameInEnglish
For Portuguese:
/nomeControladorEmPortugues/nomeAcaoEmPortugues
The Portuguese version must call the same action as the URL for English.
Please ignore this question. I just found the answer on http://blog.maartenballiauw.be/post/2010/01/26/Translating-routes-(ASPNET-MVC-and-Webforms).aspx
You can also check out a plugin called AttributeRouting that can help you archieve this. The great thing about it is that it's going to be included by default in future versions of ASP.NET MVC.

Hide the part of site address in toolbar browser in asp.net

I want to hide part of the address in the browser toolbar in asp.net.
For example, if it's http://mysite.com/News/Shownews.aspx?ID=-1&Num=20, it should change to http://mysite.com/ on every page.
I visit some websites that do exactly like this. Can anybody help me?
You probably want UrlRewrite.
Or, you can use asp.net mvc, it has routing feature.
No idea why you would do such a thing, but some hacky solution comes to mind:
http://mysite.com/News/Shownews.aspx?ID=-1&Num=20 will respond with a redirect to http://mysite.com/ and stashes whatever information is necessary in cookie/session state/... (like ie. the complete original request URL)
The controller handling http://mysite.com/ grabs the state and renders the appropriate output
Of course this might introduce some race conditions dependent on the exact method used to store the relevant state.
All in all that whole undertaking is a pretty bad idea thinking of principles like REST...but since you asked for it...
Yep, URL rewriting is what you're looking for most likely: http://msdn.microsoft.com/en-us/library/ms972974.aspx is a broad overview of the topic.

Can you determine the name of the route followed from your webforms page?

I have a ASP.NET 3.5 webforms project I have enabled routing over.
I also have in the project a number of controls doing different things based on what page they are currently being shown in. It would seem that the most straightforward way to control this different behavior is to discover which route was used to load the page and then do things according to that.
However, I can't seem to find a way to discover the route bar looking at the actual request URL and running a regex over it which isn't great. Does anyone know a way to look it up some other way?
Update: there still doesn't appear to be a way to do this in ASP.NET 4.0. Hopefully someone else has figured this out?
It looks like Phil Haack has answered this question in a blog post on his site: http://haacked.com/archive/2010/11/28/getting-the-route-name-for-a-route.aspx
In a .NET 4 webforms app, I used this to determine the route definition.
string myOperation =
((System.Web.Routing.Route)(Page.RouteData.Route)).Url;
//string has value "Stop" or "Start"
Let's say your routes are like so:
routes.MapPageRoute("StopEmailAlerts",
"Stop/{SomeToken}",
"~/Emailing.aspx", false);
routes.MapPageRoute("SendEmailAlerts",
"Start/{SomeToken}",
"~/Emailing.aspx", false);
I posted a couple of simple extension methods you can use to get/set the route name on this post. Seems simpler (to me) than Haack's solution.

Resources