我收到 500 服务器错误:https://screencast.com/t/n7VRzxSSi6Cors 已经在 web api 上启用。https://screencast.com/t/3Fl70yX0awOweb api 代码是这样的:public class TenantController : ApiController { public async Task<List<Tenant>> GetTenants() { var tenantStore = CosmosStoreFactory.CreateForEntity<Tenant>(); return await tenantStore.Query().Where(x => x.TenantId != null ).ToListAsync(); } public async Task<IHttpActionResult> GetTenant(string tenantId) { var tenantStore = CosmosStoreFactory.CreateForEntity<Tenant>(); var tenant = await tenantStore.Query().FirstOrDefaultAsync(x => x.TenantId == tenantId); if (tenant == null) { return NotFound(); } return Ok(tenant); } public async Task<IHttpActionResult> PutTenant([FromBody]Tenant tenant, HttpPostedFile certificateFile) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureStorageKey"].ToString()); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container. CloudBlobContainer container = blobClient.GetContainerReference(ConfigurationManager.AppSettings["certificatesContainer"].ToString()); // Retrieve reference to a blob named "myblob". CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob"); // Create or overwrite the "myblob" blob with contents from a local file. blockBlob.Properties.ContentType = certificateFile.ContentType; blockBlob.UploadFromStream(certificateFile.InputStream); var tenantStore = CosmosStoreFactory.CreateForEntity<Tenant>(); tenant.CertificatePath = blockBlob.Uri;我在发布后附加了调试器,但代码从未在 Visual Studio 中被命中
1 回答
忽然笑
TA贡献1806条经验 获得超5个赞
要初始化你的状态this.state = { TenantId: '', TenanrUrl:'', TenantPassword:''};,但你正在使用tenantid,tenanturl以及tenantpassword在你的代码。
由于tenantid、tenanturl和tenantpassword最初不在您的状态,您将开始提供undefined您的输入,直到您调用setState并更新它。这将使输入从不受控制变为受控制。
您可以通过更改初始状态修复它以默认值tenantid,tenanturl以及tenantpassword代替:
constructor(props) {
super(props);
this.state = { tenantid: '', tenanturl: '', tenantpassword: '' };
this.handleChangeTenantUrl = this.handleChangeTenantUrl.bind(this);
this.handleChangeTenantPassword = this.handleChangeTenantPassword.bind(this);
this.handleChangeTenantId= this.handleChangeTenantId.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
};
- 1 回答
- 0 关注
- 138 浏览
添加回答
举报
0/150
提交
取消