我刚刚用我的新服务器尝试了一些东西,并且我发现了我在MVC应用程序中所做的一个很大的缺陷.
所以在applikation中发生的事情是:人们可以访问页面和登录,当人们登录时,他们可以在服务器上的自己的文件夹中上传文件.然后他们可以在需要时访问它们.但我发现的问题是:如果输入正确的网址,人们可以看到他们想要的任何文件夹.例如 :
URl可以命名为:testnameweb.com/Upload/testUserName/testfilename.png,在这种情况下输入url的人,可以看到testfilename.png文件.但是,如果同一个人进入:testnameweb.com/Upload/
他们可以看到任何人的文件夹,并以他们想要的任何方式浏览服务器.
知道如何防止这种情况吗?
过去两天我试图弄清楚如何通过javascript帮助选择下拉列表中的新项目时动态更新复选框列表.
我一周前做过同样的事情,我应该从下拉列表更新到下拉列表.
到目前为止我得到了什么:
视图
@using (Html.BeginForm())
{
@Html.DropDownListFor(x => x.User, (IEnumerable<SelectListItem>)Model.UserList, "-- vælg bruger --")
if (Model.checkboxlist != null)
{
for (var i = 0; i < Model.checkboxlist.Count; i++)
{
<div class="editor-label">
@Html.CheckBoxFor(c => Model.checkboxlist[i].check)
@Html.LabelFor(c => Model.checkboxlist[i].Id, Model.checkboxlist[i].Id)
@Html.HiddenFor(c => Model.checkboxlist[i].Id)
</div>
}
}
}
<script type="text/javascript">
$('#User').change(function () {
alert('HEJ!');
var selectedUser = $(this).val();
alert(selectedUser);
if (selectedUser != null && selectedUser != '-- vælg bruger --' && selectedUser != '') {
$.getJSON('@Url.Action("getPdfCheckBoxList","Admin")', { username: selectedUser },
function (employee) …Run Code Online (Sandbox Code Playgroud) 我有我的迁移:
class CreateCourses < ActiveRecord::Migration
def change
create_table :courses, :id => false do |t|
t.uuid :id, :primary_key => true, :null => false
t.datetime :date_start, :null => false
t.float :price, :null => false
t.datetime :date_end
t.text :description
t.text :location, :null => false
t.timestamps
end
end
end
Run Code Online (Sandbox Code Playgroud)
create我的控制器中有我的方法:
def create
course = Course.new(params[:course])
if course.save
render :nothing => true
else
render "public/422", :status => 422
return
end
end
Run Code Online (Sandbox Code Playgroud)
现在,当我create用任何数据调用我的方法时,它会在我的Course表中创建一个新的空行.但是,我想确保发送给create的对象实际上是一个Course对象,并且位置和价格(例如)不是空的并且存在.
我有ASP.NET MVC背景,所以我刚开始学习Rails.
PS如何在成功创作时返回成功200响应,而不是 render :nothing => true?
我需要找到一种方法,如何用.png图片填充整个封面页,并在页面的底部放置一些文本,图片不会.
现在我通过使用它来伸展它:
document.DefaultPageSetup.LeftMargin = 0;
document.DefaultPageSetup.TopMargin = 0;
Run Code Online (Sandbox Code Playgroud)
但是上边距仍然留下了som mm的空间(而不是顶部有一些白色的图片.)
PS将来我需要在封面图片上面放一张图片.所以它实际上必须是2层.有什么建议?
这是我的界面和类:
public interface IServiceFactory<T, Y> where T : class where Y : class
{
T Create(ModelStateDictionary modelState);
}
public class ServiceFactory<T, Y> : IServiceFactory<T, Y>
where T : class
where Y : class
{
public T Create(ModelStateDictionary modelState)
{
var x = (T) Activator.CreateInstance(typeof (Y), new ModelStateWrapper(modelState));
return x;
}
}
Run Code Online (Sandbox Code Playgroud)
Simple Injector的容器寄存器:
container.RegisterManyForOpenGeneric(typeof(IServiceFactory<, >), typeof(IServiceFactory<, >));
Run Code Online (Sandbox Code Playgroud)
如何设置Simple Injector以使用包含多个类型的泛型?