ASP.NET MVC4 “BIN” a reserved keyword?

I have a stock query application that returns data based upon a stock symbol.

Basically, the AJAX call goes to ~/Stocks/GetStockData/{id} where the {id} is the stock symbol.

This works fine… generally. Today I found that the stock “Progressive Waste Solutions Ltd.”, which has a symbol of BIN, blew up. Looking at the return data in the browser, I see it’s returning a 404 for this symbol.

It occurred to me that BIN might be a reserved word, asking for some binary file or something. Is this the case? How do I work around this without a whole lot of effort? Are there other keywords that will also cause this problem?

UPDATE

Per Artyom Neustroev, this could be a reserved keyword, and would be protected from routing to. He referenced an article which referenced a website which stated the way around this was to add the following configuration setting in the config file:

<configuration>
  <system.web>
    <httpRuntime relaxedUrlToFileSystemMapping="true"/>

    <!-- ... your other settings ... -->
  </system.web>
</configuration>

 

The routing mechanism takes into account hidden directories and files (like web.config, /bin, etc) and hides them from people. For some of these, the rules can be relaxed a bit, as they are handled in code. These “keywords” are: CON, COM1, COM2, COM3, COM4, LPT1, LPT2, AUX, PRN, and NUL. These can actually be referenced with a change to your web.config file as such:

<configuration>
  <system.web>
    <httpRuntime relaxedUrlToFileSystemMapping="true"/>

    <!-- ... your other settings ... -->
  </system.web>
</configuration>

Increment “sequence” column based on alphabetical order of another column

Assume the following schema:

text|sequence
----|--------
Foo |       1
Bar |       2
Baz |       3

How would I UPDATE the sequence column so it incremented starting at 1 with no gaps based on the alphabetical order of the text column?

The resulting data would look like:

text|sequence
----|--------
Foo |       3
Bar |       1
Baz |       2

 

Try this:

UPDATE A 
SET A.sequene = B.sequence 
FROM tableA A 
INNER JOIN (SELECT text, ROW_NUMBER() OVER (ORDER BY text) sequence 
            FROM tableA 
           ) AS B ON A.text = B.text

How to add leading zeros to a number

I saw the question “How to add leading zeros to a number” on the ASP.NET forums countless times before. And often the answers provide solutions that work, but are overkill as well.

The two cleanest methods I know are String.Format and PadLeft.

   1:  Console.WriteLine("Using .ToString()");
   2:  Console.WriteLine(String.Format("{0:0000}", 16));
   3:   
   4:  Console.WriteLine("-------------------");
   5:   
   6:  Console.WriteLine("Using .PadLeft()");
   7:  Console.WriteLine(Convert.ToString(16).PadLeft(4, '0'));

You can see the result here.

//Using .ToString()
//0016
//-------------------
//Using .PadLeft()
//0016

Get Google Maps Api Key for Website

Introduction:

Here I will explain how to generate Google map api key for website or create Google maps api key for localhost website or get Google maps api key for website .

Description:

If we want to use Google maps in website first we need to get api key from Google for that you need to follow below steps

First open the APIs Console page at https://code.google.com/apis/console and log in with your Google Account. Whenever you open above url it will show like as shown below

Now click on Create project once login click on the Services link from the left-hand menu.

Once open Services tab check for Google Maps API v3 and click on “off” to activate that service in the next screen select conditions and click “Accept” button.

Now Click on API Access link from the left-hand menu. Once if it opens Your API key is available from the API Access page, in the Simple API Access section. In that Maps API applications click on Create new Browser key button >> in next window give url of your application and click Create

Once we got the key Simple API Access section will show data like as shown below

This way we can generate Google MAP API key to use this key to integrate in websites.

How to add google map to your website.

Marker

To add the Google map on your asp.net web page. Simply paste the code given below.

<script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;key=AIzaSyBVaXuUwG51lC0vu6q-E-PzaCGI_u6UX1A&sensor=false&#8221;
type=”text/javascript”></script>
<script type=”text/javascript”>

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById(“map_canvas”));
map.setCenter(new GLatLng(51.659369, -0.029843), 15);
map.setUIToDefault();
marker = new GMarker(new GLatLng(51.659369, -0.029843));
map.addOverlay(marker);
}

}

</script>

Insert a div named “map_canvas” where you want to put map on your page.

<div id=”map_canvas” style=”width: 300px; height: 350px”></div>

For showing any address just pass the longitude and latitude values for your address and replace:
map.setCenter(new GLatLng(51.659369, -0.029843), 15);

Get longitute and latitute from address for google map

Note: you also need to change the Key for your project. You can generate new key from: https://code.google.com/apis/console/

Get Google Map API Key for website