I created a webpage by classic asp. A date was displayed in this page. But I want to display it with request country dateformat. So, I need to know which request came from? How can I know it? Thanks.
You will probably need to store a cross reference between language and the language's preferred date format. You can get the users language by using
Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
Related
sorry but I am really confused here. I read some threads but they could not make it clear for me.
I have an MVC 4 website which is expecting visitors from around the world. The website is in Arabic, and I want all visitor to use the Arabic language, ar-SA culture.
Now comes the problem: dates. Visitors should be able to choose from two supported calendars. Some will choose GregorianCalendar and some will choose HirijiCalendar.
Q1: Where to set the calendar (user-dependent) for better performance?
What I have done is a base controller which all controllers inherit from. In OnActionExecuting, I try to change the: Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.Calendar
to the visitor preference, which was read from database upon signing in.
Q2: Will this line of code affect: the current request only, the current session only (this visitor), or the whole application (all visitors)? I am afraid it will affect others, I do not know anything about thread scope… I am afraid that changing thread calendar in OnActionExecuting every time is too bad for the performance…
Q3: If I store dates in database according to UTC (like AddedOn, EditedOn), where should I convert it to whatever time zone of a visitor? in controller code? Will the website become slow to do this every time I query the database? What is the best practice here?
Thank you and excuse me, I'm a beginner.
i want to know how to send variables like Facebook.
ex: facebook.com/action-man.
here they will show actionman profile put i know how to send like this ex: facebook.com/users.aspx?user=actionman. so i want to know how to just send the username without the query parameter. thanks in advance
Use mvc routing engine. With MVC it is a must, so you should be already familiar with it.
If not, here you go:
http://www.asp.net/mvc/overview/controllers-and-routing
I'm going through crawling wikipedia using website downloader for windows, i was looking through the whole options in this tool to find an option to download wikipedia pages for specific period, for example from 2005 untill now.
Does anyone get any idea about crawling the website in specific period of time ?
Why not download the SQL database containing all of Wikipedia?
You can then query it using SQL.
Give a try to the Wikipedia API and your programming skills.
There should be no need to do web scraping; use the MediaWiki API to directly request the information you want. I'm not sure what you mean by "wikipedia pages for a specific period" - do you mean last edited at a certain time? If so, while skimming, I noticed an API call that lets you get a look at the last n revisions; just ask for the last revision and see what its date is.
It depends if the website in question offers the archive and mostly don't so its not possible in a straightforward way to crawl a sample started from specific date. But you can implement some intelligence in your crawler to read the page created date or something like that.
But you can also look at Wikipedia API at http://en.wikipedia.org/w/api.php
I'm sorry for maybe making such a basic question but in ASP.NET websites what does the __VIEWSTATE input field represent?
Also, is there any way to compute it's value (based on the values of other form fields)?
EDIT
I understand that __VIEWSTATE, as the name suggests, maintains the values of form field values in webpages however what I'm interested in knowing is how this state (the string) is generated. If I base64_decode any __VIEWSTATE string all I see is a bunch of cryptic HTML.
Is there any way to better understand what exactly is being encoded? I've searched on past questions and I've found some tools that can do this like this one, but unfortunately it doesn't seem to work.
The reason I'm asking this is because I've access to a web service API that gives me most of the values I need to work with. However I also need an additional field that is only available on the last stage of the form. I already contacted the web service provider but unfortunately and they're not going to update their API so soon. I was hoping I could prefill the form initial values using the web service data and then calculate the __VIEWSTATE to access the last field that shows up on the last stage of the form, it would make the whole process a lot faster.
Not sure if I made myself clear enough though...
Paul Wilson has a very good article: ViewState: All You Wanted to Know
VIEWSTATE can be deserialized with the LosFormatter class.
A quick Google search answers the question:
http://msdn.microsoft.com/en-us/library/ms972976.aspx
First sentence:
Microsoft® ASP.NET view state, in a
nutshell, is the technique used by an
ASP.NET Web page to persist changes to
the state of a Web Form across
postbacks.
If you really want to understand it well, see Dave Reed's article about ViewState.
Do take a look at the biter script posted at http://forums.techarena.in/windows-software/1329157.htm.
That script shows how to set up and use __ViewState and other .NET variables.
That script logs into a .NET site, and gets stock values, without going thru a browser. Instead of user doing it manually, the script does it programmatically.
What do you mean by compute it's value?
Assume that it is a compressed (actually Base64 encoded) pair of your form fields/values in text form, which gets serialized into server side objects for you to work with.
The easiest way of doing this in Razor is putting this on a view:
#{
throw new Exception();
}
I'm looking for a bit of advice with regards to the structure of an application I'm tasked with.
I need to have a series of webforms to store some data, most of the data is the same but each form would have some differeing data depending on the form used.
Would a base class then a series of classes inheriting from this for the specific data be best to use?
As in:
order - compAOrder
- compBOrder
- compCOrder
How about strucuting the database for this sort of application structure?
The answer to this kind of question is allways "It depends" but here is a possible solution:
Program the system with a single web page for form data input.
Use a query string value to identify which form it is.
Hide and enable fields depending upon which form it is.
Have a single data table that has all the possible fields.
Hope this helps
Shiraz
I eventually went with a catch-all table with all the fields and different forms.