Dear all readers!

Our programming topics will moved to GEEKSSHIP.COMGEEKSSHIP.COM is a new developer community for Vietnamese Developers and developers from all over the world. It supports multiple  languages and can store all edited versions of a topic. GEEKSSHIP.COM is really a new generation of developer community.

 

Thưa tất cả bạn đọc!

Tất cả các bài viết về chủ đề lập trình SFI.VN Team sẽ chuyển sang website GEEKSHIP.COM. GEEKSSHIP.COM là một thế hệ cộng đồng dành cho lập trình viên mới cho Việt Nam và các lập trình viên trên toàn thế giới. GEEKSSHIP.COM hỗ trợ đã ngôn ngữ và nó sẽ lưu tất cả các phiên bản của một chủ đề để có thể tham khảo ngược. GEEKSSHIP.COM thực sự là điểm đến mới của cộng đồng lập trình viên!

 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

I'm writing a asp.net mvc website that presents PPT file, so I use ZohoShow as storage and Zoho Show Viewer as a presenter.

 Zoho Show API to upload a ppt/pps file.

My code:

  1. public static void Upload(string username, string password, string apiKey, string filePath)   
  2.        {   
  3.            var ticket = GetTicket(username, password);   
  4.            if (string.IsNullOrEmpty(ticket)) return;   
  5.   
  6.            var requestUrl = "http://show.zoho.com/api/private/xml/uploadpresentation?apikey=" +    
  7.                apiKey + "&ticket=" + ticket;   
  8.   
  9.            var request = (HttpWebRequest)WebRequest.Create(requestUrl);   
  10.            request.Method = "POST";   
  11.            //request.Headers = new WebHeaderCollection();   
  12.            //request.Headers.Add("Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-shockwave-flash, */*");    
  13.            string boundary = "-----------------------------" + DateTime.Now.Ticks.ToString("x");   
  14.            //string boundary = "------" + Guid.NewGuid().ToString().Replace("-", "");   
  15.            request.ContentType = "multipart/form-data; boundary=" + boundary;   
  16.            request.KeepAlive = true;   
  17.            request.Credentials =CredentialCache.DefaultCredentials;   
  18.   
  19.   
  20.            var postDataStream = new MemoryStream();   
  21.            const string newLine = "\r\n";   
  22.            var streamWriter = new StreamWriter(postDataStream);   
  23.            streamWriter.Write(boundary + newLine);   
  24.            streamWriter.Write("Content-Disposition: form-data; name=\"content\"; filename=\"" + (new FileInfo(filePath)).Name + "\"" + newLine);   
  25.            streamWriter.Write("Content-Type: application/vnd.ms-powerpoint"+ newLine + newLine);   
  26.            streamWriter.Flush();   
  27.   
  28.            var fileContent = (new FileInfo(filePath)).OpenText().ReadToEnd();   
  29.            streamWriter.Write(fileContent);   
  30.            streamWriter.Write(newLine);   
  31.            streamWriter.Write(boundary+newLine);   
  32.            streamWriter.Flush();   
  33.   
  34.            streamWriter.Write("Content-Disposition: form-data; name=\"submit\"" + newLine + newLine);   
  35.            streamWriter.Write("importpresentation" + newLine);   
  36.            streamWriter.Write(boundary+ "--" + newLine);   
  37.            streamWriter.Flush();   
  38.   
  39.            request.ContentLength = postDataStream.Length;   
  40.            using(var requestStream = request.GetRequestStream())   
  41.            {   
  42.                postDataStream.WriteTo(requestStream);   
  43.            }   
  44.   
  45.            streamWriter.Close();   
  46.            postDataStream.Close();   
  47.            //var content = new StringBuilder();   
  48.            //content.AppendLine(boundary);   
  49.            //content.AppendLine("Content-Disposition: form-data; name=\"content\"; filename=\"" + (new FileInfo(filePath)).Name + "\"");   
  50.            //content.AppendLine("Content-Type: application/vnd.ms-powerpoint");   
  51.            //content.AppendLine("");   
  52.            //var fileContent = (new FileInfo(filePath)).OpenText().ReadToEnd();   
  53.            //content.AppendLine(fileContent);   
  54.            //content.AppendLine(boundary);   
  55.            //content.AppendLine("Content-Disposition: form-data; name=\"submit\"");   
  56.            //content.AppendLine("");   
  57.            //content.AppendLine("importpresentation");   
  58.            //content.AppendLine(boundary + "--");   
  59.            //Console.WriteLine(content);   
  60.            //File.WriteAllText(@"e:\a.txt", content.ToString());   
  61.            //byte[] data = ASCIIEncoding.UTF8.GetBytes(content.ToString());   
  62.            //request.ContentLength = data.Length;   
  63.   
  64.            //var requestStream = request.GetRequestStream();   
  65.            //requestStream.Write(data, 0, data.Length);   
  66.            //requestStream.Close();   
  67.   
  68.            var response = request.GetResponse();   
  69.            // Get the stream containing content returned by the server.   
  70.            var responseStream = response.GetResponseStream();   
  71.            // Open the stream using a StreamReader for easy access.   
  72.            var reader = new StreamReader(responseStream);   
  73.            // Read the content.   
  74.            var responseFromServer = reader.ReadToEnd();   
  75.            Console.WriteLine(responseFromServer);   
  76.            // Display the content.   
  77.            ///ViewData["content"] = responseFromServer;   
  78.            //Console.WriteLine(responseFromServer);   
  79.            // Clean up the streams.   
  80.            reader.Close();   
  81.            responseStream.Close();   
  82.            response.Close();   
  83.        }  

 

But no matter how i try, Zoho Show server always refuse the request:System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

If there is anybody interested with HttpWebRequest and ZohoShow, please give me some hint to make it works.

Thanks!

 

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in: .NET , ASP.NET  Tags:
lehoangdung posted on February 12, 2010 15:31

Well, it's time to dance with VS2010 RC. I've used VS2010 Beta 2, but I didn't happy too much because It was really slow. In this RC version, everything seems changing, on Scottgu's blog, he add some comments from audience:

  • @DanWahlin: The performance improvements with Visual Studio 2010 RC compared to previous builds are huge. Really happy with what I'm seeing so far.
  • @peterbromberg: VS2010 RC: I must admit, I am impressed. Major speed and performance improvements. They are obvious immediately!
  • @Nick_Craver: RC performance is ridiculously faster, can't wait to switch over full time!
  • @Rlz2cool: Just tried VS2010 RC. One word incredible. Super fast, great build with things I saw in earlier releases fixed. So awesome.
  • @ddotterer: Trying out VS2010 RC: Snappier UI, much faster intellisense, significant build time reduction, etc. Overall: AWESOME JOB
  • @tomkirbygreen: Oh my goodness, VS2010 RC is much, much faster. Kudos to the VS perf team and everyone else. Uninstalling Visual Studio 2008 :-)
  • @JoshODBrown The developers on the Visual Studio 2010 RC must have had their usual beverages replaced with unicorn tears or something. #VS2010 #awesome
  • @jbristowe: Holy Butterball! VS 2010 RC is crazy fast. It makes me feel like this: http://bit.ly/cPaOvE
Voila, they said that, but we must try to know is VS 2010 RC good enough. 

I'm installing it...

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in: .NET , ASP.NET , ASP.NET MVC  Tags:
lukepro posted on December 4, 2009 19:10

 

RESAPER :

ReSharper cung cấp giải pháp:

Hiển thị  toàn bộ  lỗi và được tô sáng

Loại bỏ mã dư thừa

Đưa ra giải pháp tức thì  cho các lỗi tìm thấy , phân tích giá trị ,đưa ra khung chú thích

Tính năng hiệu chỉnh code làm cho code gọn gàng và dễ nhìn = phím nóng Ctrl+ K+D

Hỗ trợ  công cụ test ,chạy thử nghiệm và gỡ rối

Chuyển hướng tiện dụng như goto  và tính năng tìm kiếm nhanh lẹ như:

Xác định vị trí trong Solution Explorer,xem lại nhưng tìm kiếm gần đây

và rất nhiều hữu ích khác

Download: http://www.jetbrains.com/resharper/download/index.html

 

 

Jquery intellisense Dành Cho vs 2008:

Các bước cài đặt :

B1: Cài đặt thêm VS 2008 SP1 vào cho bản VS 2008(nghĩa là bạn phải có VS2008 trước)

DownLoad :http://msdn.microsoft.com/en-us/vstudio/cc533448.aspx

B2: Cài đặt VS 2008 Patch KB958502 để hổ trợ "-vsdoc.js" Intellisense Files

Download: http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736

B3:Download file jQuery-vsdoc.js

DownLoad :http://docs.jquery.com/Downloading_jQuery#Download_jQuery

 

Cách sử dụng :

Cái thả jquery-1.3.2-vsdoc.js vào

 

 

 

 

 

 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in: .NET , ASP.NET , Visual Studio , JQuery  Tags:
lequangthai posted on November 21, 2009 07:02

In this article,I will talk about how to use radio button in asp.net MVC.

To begin with open Visual Studio 2008 and choose File > New > Project > ASP.NET MVC.The first thing to do is to create a class that will be the structure of our data to fill radio button.Add new class to the project and name it RadioOption.Add the following code to the RadioOption class:

I will create a controller and name it RadioListController for this example. In the constructor of controller,following code to add data to List<RadioOption>

In method Get of action Create,following code to return a list of RadioOption to view for fill data to radio button.

In RadioListController,right click,choose Add View to genarate View of action,in the top of View,fill this code:

And following code to genarate radiobutton.

In method Post of action Create,fill this code:

"return RedirectToAction("Create", new { valueOfRadio = radio.ToString() });" to return value of radio button be selected to View of method Get of action Create to check value of radio be choose.

To do that,add this command to method Get of action Create.

ViewData["valueOfRadio"] = valueOfRadio;

This is full code of RadiolistController.cs

This is full code of View Create.aspx

Looking forward feedback from you!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in: ASP.NET , ASP.NET MVC  Tags:

Page List

    Calendar

    «  September 2010  »
    MoTuWeThFrSaSu
    303112345
    6789101112
    13141516171819
    20212223242526
    27282930123
    45678910
    View posts in large calendar

    Recent Comments

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010 SFI.VN Team