About

Camalot.Common contains extensions, objects and other methods that I found myself rewriting over and over. I made this library so I did not have to duplicate the code. You may find these useful, or you may not.



Nuget

PM> Install-Package Camalot.Common
PM> Install-Package Camalot.Common.Mvc5
PM> Install-Package Camalot.Common.Mvc4
PM> Install-Package Camalot.Common.Mvc


License



Documentation



Causes all ajax request to not be cached by the browser.

Indicates that a method can only be called from an Ajax request.

Decorate your method or class with the AjaxOnly attribute and it will only be able to be called via ajax.

This checks the request headers for the request verification token if the request is an ajax request.

This attribute will work in place of ValidateAntiForgeryTokenAttribute.

Decorate your method with the validation attribute
In your ajax call to post the data, you will want to do something like the following:

Indicates that the requests should be compressed using the methods accepted by the clients browser. (GZIP or DEFLATE)

References

An attribute to give an enum a display value

An attribute to specify that an enum should be ignored when looking at the enums via reflection.

An attribute that gives an enum a string value to use.

Indicates that the request should never be cached by the browser.

Requires an action/controller to be called only from the specified host

Gets or sets the name of the host.

Describes that the controller, area, or action should be not visited by a web crawler robot.

Disallow an entire Area Registration
Disallow an entire Controller
Disallow a specific Action within a Controller
Setup the web.config for handling the robots.txt requests.
Global.asax setup.

References

Gets or sets the area.

This can be left empty if the attribute is on an AreaRegistration.



Registers the routes.

Parameters

Name Description
routes The routes.



Serves up the route /robots.txt

Disallow an entire Area Registration
Disallow an entire Controller
Disallow a specific Action within a Controller
Setup the web.config for handling the robots.txt requests.
Global.asax setup.

References



Returns content based on the accept types passed in as headers.

Parameters

Name Description
data The data.

Serializes the data to bson and returns a BsonResult

Parameters

Name Description
data The data.

Compresses the response using the browsers acceptable content compressions (GZIP or DEFLATE).

References

Returns an HTML select element for each field by the specified enum items and HTML attributes.

Parameters

Name Description
name The name of the select field.
selected The selected value.
optionLabel The option label.
htmlAttributes An object containing a list of html sttributes to apply to the select element.

Serializes the data to json and returns a JsonResult

Parameters

Name Description
data The data.

Serializes the data to json and returns a JsonPResult

Parameters

Name Description
data The data.

Serializes the data to json and returns a JsonPResult

Parameters

Name Description
data The data.
callback The callback.

Loads bundle configuration from web configuration in <camalot.common> section

References

Gets a UrlHelper for the Controller Context.

URL decodes a string.

Parameters

Name Description
encoding The encoding.

Encodes a URL string using the specified encoding object.

This method can be used to encode the entire URL, including query-string values. If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. For example, when the characters < and > are embedded in a block of text to be transmitted in a URL, they are encoded as %3c and %3e.

Parameters

Name Description
encoding The Encoding object that specifies the encoding scheme.

References

returns the content as XML

Parameters

Name Description
data The data.