![](/img/trans.png)
[英]The following code gives an error: 'Session' is a type, which is not valid in the given context. What is causing the error?
[英]What is the type of “context” in this code?
我正在嘗試使用C#在我的asp.net Web應用程序中生成QR代碼。 我使用ZXing庫在線發現了這個教程,但它在代碼中使用了“context”變量,我不確定它的類型。 這是一段代碼:
var writer = new BarcodeWriter();
writer.Format = BarcodeFormat.QR_CODE;
var result = writer.Write("http://www.dotnetthoughts.net");
var barcodeBitmap = new Bitmap(result);
barcodeBitmap.Save
(context.Response.OutputStream, ImageFormat.Jpeg); //what is this context value ?
context.Response.ContentType = "image/jpeg";
context.Response.End();
這是網站的來源: http : //www.dotnetthoughts.net/how-to-generate-and-read-qr-code-in-asp-net/
“context”變量是HTTPContext,正如@Jeroen Vannevel在評論中提到的那樣,它是頁面中預定義的變量。 但是我不得不將“C”(即使用“Context”而不是“context”)大寫,以便能夠在沒有任何定義的情況下使用它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.