Jan 21, 2015
2 mins read
先開個Web專案
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> <caching> <outputCache defaultProvider="MyRedisOutputCache"> <providers> <!-- Either use 'connectionString' and provide all parameters as string OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. --> <!-- 'databaseId' and 'applicationName' can be used with both options. --> <!-- <add name="MyRedisOutputCache" host = "127.0.0.1" [String] port = "" [number] accessKey = "" [String] ssl = "false" [true|false] databaseId = "0" [number] applicationName = "" [String] connectionTimeoutInMilliseconds = "5000" [number] operationTimeoutInMilliseconds = "1000" [number] connectionString = "<valid StackExchange.Redis connection string>" [String] /> --> <add name="MyRedisOutputCache" type="Microsoft.Web.Redis.RedisOutputCacheProvider" host="10.9.11.64" accessKey="" ssl="false" /> </providers> </outputCache> </caching> </system.web> </configuration>
namespace WebApplication1 { using System;public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write(DateTime.Now); } }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %> <%@ OutputCache Duration="60" VaryByParam="*" %> <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml”> <head runat="server”> <meta http-equiv="Content-Type” content="text/html; charset=utf-8”/> <title></title> </head> <body> <form id="form1” runat="server”> <div>
</div> </form>
</body> </html>
Sharing is caring!