我正在尝试按照these说明为blob CDN端点设置自定义域名,但似乎无法使用子域static.mydomain.com访问我的内容。我已经在我的注册商处创建了以下记录:
Subdomain: static
Type: CNAME
TTL: 7200
Data: blobconatinername.blob.core.windows.net.
例如,我可以访问此文件(注意https): https://blobcontanername.blob.core.windows.net/somefile.mp3
但是尝试访问此文件
http://static.mydomain.com/somefile.mp3
我收到无效的URI错误(错误400):
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>InvalidUri</Code>
<Message>
The requested URI does not represent any resource on the server. RequestId:c5ec4859-0001-0079-0bf8-961dfa000000 Time:2016-04-15T09:22:32.1317877Z
</Message>
<UriPath>
http://static.mydomain.com/somefile.mp3
</UriPath>
</Error>
分辨率?
答案 0 :(得分:1)
您可以通过CDN端点sh
?
不应该 enter code here
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace Attributes
{
[AttributeUsage(AttributeTargets.Property)]
public sealed class MinimumPaymentDateAttribute : ValidationAttribute, IClientValidatable
{
private readonly string errorMessage;
public string ValidationErrorMessage { get { return errorMessage; } }
/// <summary>
/// Constructor for intializing variables
/// </summary>
public MinimumPaymentDateAttribute()
{
}
/// <summary>
/// Constructor for intializing variables
/// </summary>
/// <param name="validationErrorMessage"></param>
public MinimumPaymentDateAttribute(string validationErrorMessage)
{
this.errorMessage = validationErrorMessage;
}
/// <summary>
/// Validation for of Rule implement Client Validation
/// </summary>
/// <param name="value"></param>
/// <param name="validationContext"></param>
/// <returns></returns>
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
if (null != validationContext)
{
PaymentInformation paymentInfo = (PaymentInformation)validationContext.ObjectInstance;
if (value != null && validationContext != null)
{
if (paymentInfo.PaymentDate < paymentInfo.MinDate)
{
return new ValidationResult(this.ValidationErrorMessage);
}
}
}
return ValidationResult.Success;
}
/// <summary>
/// Validation rules client side for Minimum Date
/// </summary>
/// <param name="metadata"></param>
/// <param name="context"></param>
/// <returns>IEnumerable<ModelClientValidationRule></returns>
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
{
string errorMessage = this.FormatErrorMessage(metadata.DisplayName);
ModelClientValidationRule MinDateRule = new ModelClientValidationRule();
DateTime? validationData = GetValidationParameters(context.Controller.ViewData.Model);
MinDateRule.ErrorMessage = errorMessage;
MinDateRule.ValidationType = "validminpaymentdate";(Java script function name)
MinDateRule.ValidationParameters.Add("mindate", validationData);
yield return MinDateRule;
}
/// <summary>
/// Checking for Model type for handling Different ViewData
/// </summary>
/// <param name="model"></param>
/// <returns>string[]</returns>
private static DateTime? GetValidationParameters(object model)
{
DateTime? MinDate=null;
if (model.GetType() == typeof(PaymentInformation))
{
PaymentInformation obj = (PaymentInformation)model;
return obj.MinDate;
}
else if (model.GetType() == typeof(PaymentViewModel))
{
PaymentViewModel obj = (PaymentViewModel)model;
return obj.PaymentInfo.MinDate;
}
return MinDate;
}
}
}
$.validator.addMethod("validminpaymentdate", function (value, element, params) {
var valid = true;
var mindate = new Date(params);
var valdate = new Date(value);
if (valdate < mindate) {
valid = false;
}
return valid;
});
$.validator.unobtrusive.adapters.addSingleVal("validminpaymentdate", "mindate");
指向CDN端点,而不是指向blob存储?
yourcdnendpoint.azureedge.net/path/to/file
此外,您必须验证您使用的域名。该过程在https://azure.microsoft.com/sv-se/documentation/articles/cdn-map-content-to-custom-domain/
中描述答案 1 :(得分:1)