Cocket中的Socket.io ... SocketIoClientDotNet和SocketIO4net失败

时间:2015-08-24 20:08:27

标签: c# node.js socket.io

我想开发一个简单的C#程序来连接到Node.js上的socket.io v1.x

我已经尝试SocketIoClientDotNet但它失败了!

socket.Connected = false;

当我运行程序时,服务器告诉我有两个连接,但属性:

XMLHttpRequest cannot load http://xxxxxxx.azurewebsites.net/api/PdfHandler/PdfButtonCaller.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:1570' is therefore not allowed access.
The response had HTTP status code 405.

总是!!!

这是在网上搜索解决方案的第4天,但我找不到任何东西!

谁有办法使用C#连接到Socket.io !! !!

提前致谢!

1 个答案:

答案 0 :(得分:2)

确保nodejs服务器正常工作并

c#.net 4.0up code

 function admin_reports(){
 App::import('Vendor', 'phpexcel',array('file' => 'phpexcel/PHPExcel.php'));
 if(!empty($this->params['form'])){
 ($this->params['form']['hidden'] == 'topBidder'){
            //$report = $this->Bid->getWonAuction($this->params['form']['daterange3'],$this->params['form']['daterange4']);
            $objPHPExcel = new PHPExcel();

            $report4 = $this->Bid->getTopBidder($this->params['form']['daterange5'],$this->params['form']['daterange6']);

            //var_dump($report4);

            $objPHPExcel->setActiveSheetIndex(0)
                        ->setCellValue('A1','USER ID')
                        ->setCellValue('B1','FIRST NAME')
                        ->setCellValue('C1','LAST NAME')
                        ->setCellValue('D1','NUMBER OF AUCTION WON')
                        ->setCellValue('A2', $report4);


            $objPHPExcel->setActiveSheetIndex(0);
            // Redirect output to a client’s web browser (Excel5)
            header('Content-Type: application/vnd.ms-excel');
            header('Content-Disposition: attachment;filename="topbidder.xls"');
            header('Cache-Control: max-age=0');
            // If you're serving to IE 9, then the following may be needed
            header('Cache-Control: max-age=1');

            // If you're serving to IE over SSL, then the following may be needed
            header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
            header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
            header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
            header ('Pragma: public'); // HTTP/1.0

            $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
            $objWriter->save('php://output');
        }