DEXTUpload.NET Professional
menu toggleReferences > DEXTUpload.NET.Mvc > UseDEXTAttribute

DEXTUpload.NET.Mvc
Class UseDEXTAttribute

The minimum supported version
5.0.0.0
The minimum support environment
.NET Framework 4.0
Explanation

The "UseDEXTAttribute" attribute is an action filter of the ASP.NET MVC.

This attribute checks whether or not to use the DEXTUpload.NET Professional component.

The "UseDEXTAttribute" attribute analyzes whether the HTTP request is "multipart/form-data", the request of the method is "POST", the query string has a "use=dext". In addition, when the execution of the action method is complete, it will clean remaining temporary files.

[UseDEXT]
public ActionResult Upload([Bind(Prefix = "file1")] DEXTPostedFile file)
{
    file.Element.Save();
    ...
    // If you did not call the Save method, the temporary file accessible from the "file" object at the end of the method is automatically deleted.
}

// If you do not want to remove temporary files, you can set 'WillRemoveWhenExecuted' Properties to 'false'.
[UseDEXT(WillRemoveWhenExecuted = false)]
public ActionResult Upload([Bind(Prefix = "file1")] DEXTPostedFile file)
{
    ...
}

The "UserDEXTAttribute" is not an element necessary for the upload of the file. But it checks whether the requet's method is "POST" like the "HttpPostAttribute" attribute, ensures the basic conditions for using the components are met.

And in addition, if using the "UserDEXTAttribute" attribute, temporary files that were not saved will be automatically deleted when the action method execution is completed.

If the "IFileManagement.IsKeeping" property is "true", the temporary file will be excluded from targets to be deleted.

Type
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class UseDEXTAttribute : FilterAttribute, IActionFilter
Properties

WillRemoveWhenExecuted

  • After the action method is executed, gets or sets whether or not to delete the remaining temporary files.

    By default, because it is a "true", after the action method is executed, to remove the temporary files.

  • Type

    public bool WillRemoveWhenExecuted { get; set; }