提问人:MD SHAFFAT 提问时间:11/3/2023 最后编辑:MD SHAFFAT 更新时间:11/6/2023 访问量:70
将我的 .net core API 发布到 azure 应用服务后无法编辑文件
Can'not able to edit a file after publish my .net core API to azure app service
问:
Not.rld 仅 wwroot 文件夹 .net core app 中的任何文件。当我在本地运行我的 .net core 应用程序时,我可以编辑它,即使当我将其发布到另一台服务器时它也能正常工作。但在发布 Azure 应用服务后,它无法编辑文本文件。
它显示 500 错误。
是权限相关问题吗?我该如何解决. 这在我的示例代码中。
var localRdlcFilePath = Path.Combine(Path.GetTempPath(), "prescription.rdl");
QRCodeGeneratorHelper.DownloadRdlcFileFromAzureStorage(connectionString, containerName, blobName, localRdlcFilePath);
可能是上面的线使问题。
QRCodeGeneratorHelper.DownloadRdlcFileFromAzure存储代码:
public static void DownloadRdlcFileFromAzureStorage(string connectionString, string containerName, string blobName, string localFilePath)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
CloudBlockBlob blob = container.GetBlockBlobReference(blobName);
using (var fileStream = File.OpenWrite(localFilePath))
{
blob.DownloadToStreamAsync(fileStream).Wait();
}
}
完整代码:
try
{
int extension = 1;
string mimtype = $"";
var prescription = await _prescriptionRepo.GetPriscriptionById(id);
//Azure Blob
string connectionString = "connectionstringhere";
string containerName = "namehere";
string blobName = "report/prescription.rdl";
var localRdlcFilePath = Path.Combine(Path.GetTempPath(), "prescription.rdl");
QRCodeGeneratorHelper.DownloadRdlcFileFromAzureStorage(connectionString, containerName, blobName, localRdlcFilePath);
List<ImageStorage> datasrc2 = new()
{
new ImageStorage() {Id=1,Image = GenerateQrCode("http://www.outreachforall.org/")},
};
// End Of QR code
var pres = _mapper.Map<GetPrescriptionForReport>(prescription);
Dictionary<string, string> parameter = new Dictionary<string, string>
{
{ "patientname", $"{prescription.Patient.FirstName} {prescription.Patient.LastName}" },
{ "prescriptionid", $"{prescription.PatientId}" },
{ "advice", $"{prescription.Note}" },
{ "doctorname", $"{prescription.DoctorFirstName} {prescription.DoctorLastName}" },
//{"image", imagae}
};
LocalReport localReport = new LocalReport(localRdlcFilePath);
localReport.AddDataSource("DataSet1", pres.MedicineForPrescription);
localReport.AddDataSource("DataSet2", datasrc2);
var result = localReport.Execute(RenderType.Pdf, extension, parameter, mimtype);
var foo = File(result.MainStream, "application/pdf");
foo.FileDownloadName = $"{prescription.PatientId}-{prescription.Patient.FirstName} {prescription.Patient.LastName}.pdf";
return foo;
}
catch (Exception ex)
{
// Log or handle the exception appropriately
throw;
}
答:
0赞
MD SHAFFAT
11/6/2023
#1
在这种情况下,我使用了用于测试应用程序的基本 B1 Windows 包。这就是为什么我无法以编程方式编辑任何文件的原因。
现在,我购买了用于生产的包,并将我的应用部署到 Azure 应用服务现在我的程序正在成功运行。
评论