小编Cod*_*Ari的帖子

用ajax和asp.net上传图片返回html

我正在尝试构建简单的图像上传到服务器。页面是带有 webforms 的基本 asp.net 页面。

HTML 代码 - 工作正常

<div>
 <input type="file" id="myPhoto" />
 <input type="button" id="upload" value="Upload" />
</div>
Run Code Online (Sandbox Code Playgroud)

在后端,我在 dog.aspx 中的代码是

[WebMethod(EnableSession = true)]
    public static string uploadDoc(HttpPostedFileBase file)
    {
        try
        {
        string _file = mkStorage.UploadImg(file);
        return _file;
        }
        catch (Exception e)
        {
            return e.Message;
        }
    }
Run Code Online (Sandbox Code Playgroud)

以及我在 jQuery ajax 调用中遇到的问题。它只将整页作为 html 返回到控制台。它甚至不会调用 WebMethod,因为我的刹车点不会激活。

Javascript代码

$(document).ready(function () {
        $("#upload").click(function () {
            var formdata = new FormData();
            var _image = $('#myPhoto')[0].files[0];
            formdata.append('file', _image);

            $.ajax({
                type: "POST",
                url: "dog.aspx/uploadDoc",
                data: …
Run Code Online (Sandbox Code Playgroud)

c# asp.net ajax jquery image-uploading

3
推荐指数
1
解决办法
1万
查看次数

如何从内部部署ADFS声明中获取用户组

我已经按照本文构建了具有内部部署ADFS联合的演示应用程序.

http://www.cloudidentity.com/blog/2014/02/12/use-the-on-premises-organizational-authentication-option-adfs-with-asp-net-in-visual-studio-2013/

我能够使用简单的代码为用户获取所需的信息

Dim UserEmail = System.Security.Claims.ClaimsPrincipal.Current.FindFirst(System.IdentityModel.Claims.ClaimTypes.Email).Value
Run Code Online (Sandbox Code Playgroud)

但是如何获取用户名所在的用户组并检查用户帐户是否是Active Directory中Windows组的成员?

我试图用来System.Security.Claims.ClaimsPrincipal.Current.IsInRole检查用户是否在组中,但它不起作用

vb.net asp.net adfs wif

1
推荐指数
1
解决办法
6862
查看次数

标签 统计

asp.net ×2

adfs ×1

ajax ×1

c# ×1

image-uploading ×1

jquery ×1

vb.net ×1

wif ×1