Skip to content

Instantly share code, notes, and snippets.

View isdaviddong's full-sized avatar

David Tung isdaviddong

View GitHub Profile
@isdaviddong
isdaviddong / AspNetWebFormAsyncFileUpload\default.aspx.cs
Created September 25, 2016 04:58
非同步上傳檔案後端C# code
protected void Page_Load(object sender, EventArgs e)
{
HttpPostedFile file = null;
if (Request.Files.Count > 0)
{
//找到檔案
file = Request.Files[0];
//儲存
var filePath = Server.MapPath(System.IO.Path.GetFileName(file.FileName));
file.SaveAs(filePath);
public class LineChatController : ApiController
{
[HttpPost]
public IHttpActionResult POST()
{
string ChannelAccessToken = "DETqsnH04xR7Xv...(請輸入你自己的ChannelAccessToken)...1cDnyilFU=";
try
{
//取得 http Post RawData(should be JSON)
@isdaviddong
isdaviddong / LineChatController.cs
Created December 11, 2016 05:19
Line Bot WebHook 範例
public class LineChatController : ApiController
{
[HttpPost]
public IHttpActionResult POST()
{
string ChannelAccessToken = "DETqsnH04xR7Xv...(請輸入你自己的ChannelAccessToken)...1cDnyilFU=";
try
{
//取得 http Post RawData(should be JSON)
public class ExampleController : ApiController
{
[Route("api/Example/{MethodName}")]
[HttpPost]
public IHttpActionResult ExecuteMethod(string MethodName)
{
try
{
//AssemblyLauncher
AssemblyLauncher assemblyLauncher = new AssemblyLauncher();
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="Scripts/jquery-1.9.1.min.js"></script>
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<script src="Scripts/isRockFx.js"></script>
</head>
<body>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using isRock.Framework;
using isRock.Framework.WebAPI;
namespace WebApplication15.BO
{
public class Health : BusinessLogicBase
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="Scripts/jquery-1.9.1.min.js"></script>
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<script src="Scripts/isRockFx.js"></script>
<script>
$(function () {
string Token = "你自己的LineBot Channel Access Token";
string toUserId = "傳送對象的UserId";
//建立LineBot物件實體
isRock.LineBot.Bot LineBot = new isRock.LineBot.Bot(Token);
//發送圖片訊息
LineBot.PushMessage(toUserId,
new Uri("https://圖片位置/22-124303-d8b2c4de-9a8c-48da-83f1-7c0d36de3ab6.png"));
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="WebFormsSPA._default" %>
<!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>
<script src="Scripts/jquery-1.9.1.min.js"></script>
<link href="Content/bootstrap.min.css" rel="stylesheet" />
public partial class _default : System.Web.UI.Page
{
/// <summary>
/// 計算BMI
/// </summary>
/// <param name="height">身高</param>
/// <param name="weight">體重</param>
/// <returns></returns>
[System.Web.Services.WebMethod(enableSession: true)]
public static PageMethodDefaultResult<float> BMI(float height, float weight)