-
Disable Browser Cache for Specific Page in ASP.NET MVC 3
Posted on May 21st, 2015 Add commentsGenerally when you click the “Back” or “Forward” button on the browser, the page won’t refresh unless you tell the browser not saving the cache for it. To implement “Disable Browser Cache” for specific page in ASP.NET MVC 3, just simply use the “OutputCacheAttribute” from MVC 3 framework:
12345[OutputCache(NoStore = true, Duration = 0)]public ActionResult MyAction(){//code here}
32 views
-
jQuery $.ajax()/$.get() function always get same value for IE
Posted on June 19th, 2014 Add commentsWhen I was trying to use jQuery $.ajax() or $.get() function retrieve some random value from the server side, it’s working fine on firefox or chrome, but not IE. The server side code like below (written in ASP.NET MVC):
1234567public class HomeController : Controller{public ActionResult GetRandomCount(){return Json(new Random().Next(1, 100), JsonRequestBehavior.AllowGet);}}The client side code:
12345678<a href="javascript:void(0)" onclick="CheckCount()">Check Count</a><script>function CheckCount(){$.get('/Home/GetRandomCount', function (data) {alert(data);});}</script>I’m supposed to get a random number every time I click the link, but in IE, always same one returned. Regarding Craic Computing’s Blog, that’s because IE will cache the value first returned, and trade rest requests as identical by default, so it won’t update the value since the request URL never change.
To fix this issue, just disable cache in the jQuery function as following:12345678function CheckCount(){$.ajaxSetup ({cache: false});$.get('/Home/GetRandomCount', function (data) {alert(data);});}
16 views
-
Mailbox unavailable for IIS 6 smtp service
Posted on January 18th, 2014 Add commentsAfter created a smtp virtual server and enable the smtp service, if the web application still got error such “Mailbox unavailable. The server response was: 5.7.1 Unable to relay for name@email.com”, need to do following:
- Open “IIS 6 Manager”
- Under local computer name, find SMTP virtual server, and open properties for it
- On “Access” tab, click “Relay” on “Relay restrictions” section
- Choose “Only the list below”, then add loopback ip “127.0.0.1” and server ip to the list
- Restart smtp service
12 views
-
Predicates in Lambda Expression for Entity Framework Code First
Posted on July 24th, 2013 1 commentIf I have 2 entities of “People” and “Car”, and “1” People can have “Many” Car, my code first class could be like below:
12345678910111213141516171819public class People{[key]public int ID { get; set; }public string Name { get; set; }public virtual ICollection<Car> Cars { get; set; }}public class Car{[key]public string VIN { get; set; }public string Maker { get; set; }public int OwnerID { get; set; }[ForeignKey("OwnerID")]public virtual People Owner { get; set; }}
641 views
-
Change Visual Studio Workspaces for Team Foundation After Client Name Changed
Posted on February 2nd, 2013 Add commentsAs part of source control in visual studio team foundation, ever user has their own workspace tie to the computer name of client and username on Team Foundation Server. If any one needs to change the computer name on client computer or the username, should use “tf.exe” command from the visual studio like following:
- Make sure Team Explorer has been installed. (most likely it’s there if VS2010 installed)
- Open a command line window and go to folder “C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE” (or “C:\Program Files(x86)\Microsoft Visual Studio 10.0\Common7\IDE” if on Windows 7)
- Run the command
1tf workspaces /updateComputerName:Old_Computer_Name /s:http://Tfs_server_URL
36 views
Recent Comments