我有一个存储在Azure存储上的文件,我需要从ASP.NET MVC控制器下载.下面的代码实际上工作正常.
string fullPath = ConfigurationManager.AppSettings["pdfStorage"].ToString() + fileName ;
Response.Redirect(fullPath);
Run Code Online (Sandbox Code Playgroud)
但是,PDF将在同一页面中打开.我希望通过"保存"对话框下载文件,以便用户保持在同一页面上.在转移到Azure之前,我可以写
return File(fullPath, "application/pdf", file);
Run Code Online (Sandbox Code Playgroud)
但是Azure无法正常工作.
我们正在使用 Azure redis,并希望将数据分区到多个数据库中。请注意,我们使用的是单个 Redis 服务器而不是集群,因此我不是在谈论服务器上的分区。我读到 Azure Redis 默认有 16 个数据库。使用 StackExchange.Redis,我可以通过编程方式设置数据库 1 和数据库 0 中的键。
但是,当我使用常见的 redis CLI 命令(例如 CONFIG GET Databases)时,它显示未知命令。如果我使用 SELECT xx (选择数据库 xx)然后发出 Keys *,它仍然显示数据库 0 的键。
我的一个接口有一个字符串属性,该属性取决于接口的使用位置。我想避免每次创建对象时对属性进行硬编码。我可以在构造函数中设置属性,但对象是使用工厂注入的。界面如下:
public interface IObjectStore
{
string StorageTableName { get; set;}
void UpdateObjectStore(string key, string value);
string ReadObjectStore(string key);
}
Run Code Online (Sandbox Code Playgroud)
哪个在服务中使用
public class CategoryService<T> : ICategoryService<T> where T : Company
{
private readonly IObjectStore objectStore;
public CategoryService(IObjectStore objStore)
{
this.objectStore = objStore;
objectStore.StorageTableName = "CategoryTable"; // I want to avoid this hard coding
}
...
}
Run Code Online (Sandbox Code Playgroud)
服务是使用服务工厂(Ninject.Extensions.Factory)创建的
public interface IServiceFactory
{
ICategoryService<T> CreateCategoryService<T>() where T : class;
}
Run Code Online (Sandbox Code Playgroud)
然后在控制器级别使用 Ninject 注入。这是我的绑定
bool storeInNoSql = true;
kernel.Bind<IServiceFactory>().ToFactory().InSingletonScope();
kernel.Bind<ICategoryService<Article>>().To<CategoryService<Article>>();
kernel.Bind<IObjectStore>().ToMethod(ctx => storeInNoSql ? …Run Code Online (Sandbox Code Playgroud)