post

C#6新特性,让你的代码更干净

陌路散爱 提交于 2020-01-23 00:01:11
前言 前几天看一个朋友的博客时,看他用到了C#6的特性,而6出来这么长时间还没有正儿八经看过它,今儿专门看了下新特性,说白了也不过是语法糖而已。但是用起来确实能让你的代码更加干净些。Let's try it. 1、集合初始化器 //老语法,一个类想要初始化几个私有属性,那就得在构造函数上下功夫。public class Post { public DateTime DateCreated { get; private set; } public List<Comment> Comments { get; private set; } public Post() { DateCreated = DateTime.Now; Comments = new List<Comment>(); } } public class Comment { }//用新特性,我们可以这样初始化私有属性,而不用再创建构造函数 public class Post { public DateTime DateCreated { get; private set; } = DateTime.Now; public List<Comment> Comments { get; private set; } = new List<Comment>(); } public class Comment { } 2

Sending a POST request with PHPUnit

China☆狼群 提交于 2020-01-22 15:20:12
问题 I have a symfony website, and Im trying to do some unit testing. I have this kind of test where I try to submit something: <?php namespace Acme\AcmeBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class HomeControllerTest extends WebTestCase { public function testrandomeThings() { $client = static::createClient(); $crawler = $client->request( 'POST', '/', array( "shopNumber" => 0099, "cardNumber" => 231, "cardPIN" => "adasd"), array(), array()); } but I dont think

Strongly typed view with a SelectList for DropDownList via ViewData: type mismatch on submit

我是研究僧i 提交于 2020-01-22 15:14:50
问题 I am trying to create a form in ASP.NET MVC2 RC 2 that is based on a calendar event object. The object has eventTypeId which is a System.Int32 that I need to populate with via a select list. The controller to create the initial view is: [WAuthorize] public ActionResult AddCalendarEvent() { CalendarEventTypesManager calendarEventTypesManager = new CalendarEventTypesManager(); ViewData["eventTypeId"] = new SelectList( calendarEventTypesManager.SelectAll(), "Id", "Type"); return View(); } The

Strongly typed view with a SelectList for DropDownList via ViewData: type mismatch on submit

霸气de小男生 提交于 2020-01-22 15:13:52
问题 I am trying to create a form in ASP.NET MVC2 RC 2 that is based on a calendar event object. The object has eventTypeId which is a System.Int32 that I need to populate with via a select list. The controller to create the initial view is: [WAuthorize] public ActionResult AddCalendarEvent() { CalendarEventTypesManager calendarEventTypesManager = new CalendarEventTypesManager(); ViewData["eventTypeId"] = new SelectList( calendarEventTypesManager.SelectAll(), "Id", "Type"); return View(); } The

How to send total model object as a parameter of Alamofire post method in Swift3?

那年仲夏 提交于 2020-01-22 14:51:10
问题 I have a model class like this class Example() { var name:String? var age:String? var marks:String? } I'm adding data to that model class let example = Example() example.name = "ABC" example.age = "10" example.marks = "10" After that I converted to JSON then I posted Alamofire.request(URL, method:.post, parameters: example) Alamofire not accepting parameters only its accepting like parameters = ["":"","",""]-->key value based , so I tried to convert model to JSON, JSON to dictionary, even

Call php function in javascript without waiting for response

心不动则不痛 提交于 2020-01-22 03:38:24
问题 I know how to use $.ajax. I have a Codeigniter project so I just call: url:'<?php echo base_url()."somecontroller/somefunction"?>', This is all ok but ajax waits for the response. I just want to the call the url as you would by typing it in your browser. I don't want to wait for the response because the controller does a redirect and then loads a view. Also i need to be able to send some data via POST. How can I do this? 回答1: You can use the following for sending asynchronous request with

Receipt Data is sent as bytes?

这一生的挚爱 提交于 2020-01-22 02:24:07
问题 Hi I am doing InApp purchase. Got the receipt data successfully and encoded with base64EncodedString and sent to our own server then our own server connected to apple server and the response was "Invalid Receipt".Then I added the secret key and encoded it again. Now receipt data is sent as "bytes".How to send the original receipt data to our server. func receiptValidation(productId:String,requestFrom:String) { let SUBSCRIPTION_SECRET = "My_Secret_Key" applicationDelegate.application=self var

Laravel Study(使用 Laravel )

↘锁芯ラ 提交于 2020-01-21 23:56:50
開始 伺服器及相關工具安裝自行建立,在伺服器跟目錄下 有兩種方式建立 Laravel 專案,這裡使用 composer 建立專案 使用 composer 要在 PHP 5.3.2 以上才能使用 composer 簡單說就從 packagist 網站抓檔案下來 而 packagist 裡面的檔案其實會連結到 github 上面 用 Laravel 工具,速度快,因為先下載一份到本機,建立專案時直接 copy 用 composer 工具,較慢,建立專案時都會上網抓 123 # --prefer-dist & --prefer-source 目前看起來沒差別# blog 是你指定的資料夾名稱,預設為 laravelcomposer create-project --prefer-dist laravel/laravel blog 成功之後開網頁進入 project/source 下面就會看到出現 “ Laravel 5 “ 的文字 composer 這工具是看目錄下的 composer.json 檔案來進行安裝 所以你要新增移除模組都可以改這個文件 另外 composer run-script [event] 這裡的 event 就是 composer.json 裡面的 scripts 區塊 打開 composer.json 可以看到其中一段

Ajax(2)

我与影子孤独终老i 提交于 2020-01-21 23:23:59
表单处理(get 方式) 举例(如图,建立一个表单页面) 提取输入的账号和密码 从服务器打开是这样的 提交后的结果是这样的 默认method是GET的方法 表单处理(post 方式) method = ‘post’; $_POST是一个数组并且包含了表单提交上来的数据,是PHP内置好的专门用来接数据的一个全局数组 区别(get和post) get会暴露在地址栏上 post不会暴露在地址栏上 2.get的的理论提交数据1024个字节 post没有理论上没有限制 3.get是从服务器上获取数据 post是向服务器传送数据 4.get安全性非常低 post安全性较高 5.get提交参数会在URL上显示,不安全 post不会,更安全 6.get数据使用$_GET post的数据使用$_POST 大专栏 Ajax(2) ">上传文件(files) 必须三个条件 method = ‘post’; 2.input type = ‘files’ name = ‘img’ 3. files是PHP内置提供好专门用来接收上传文件的一个全局变量 当文件上传是需要 文件默认放在临时目录下,然后转移指定目录 如果不转移走文件,文件自动删除 move_uploaded_file(filename,destination); 参数1要移动的文件,参数2移动的目标路径 举例 结果(上传成功) 登陆验证 举例 拓展

Error 404 when receive POST

别说谁变了你拦得住时间么 提交于 2020-01-21 20:05:52
问题 I need send a json POST from android to web server with php. I try a lot of codes but don't works. Now I try a simply POST with Postman, with and without send data. And always receive a 404 error. If I send data with GET the page work fine. See the php, for if you want to test: web: http://gclimb.com/Androidphp/index.php <?php $json = file_get_contents('php://input'); $obj = json_decode($json); echo $obj["username"]; echo $obj["pass"]; if ($_POST["username"]) { echo $_POST["username"]; } if (