|
Ooookkkeeeeyyyy... and?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hi, apologies, was typing the message during this time.
|
|
|
|
|
I am trying to create a dynamic text box but I am getting a null reference error.
protected void Page_PreInit(object sender, EventArgs e)
{
List<string> keys = Request.Form.AllKeys.Where(key => key.Contains("txtDynamic")).ToList();
int i = 1;
foreach (string key in keys)
{
this.CreateTextBox("txtDynamic" + i);
i++;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void AddTextBox(object sender, EventArgs e)
{
int index = pn1TextBoxes.Controls.OfType<TextBox>().ToList().Count + 1;
this.CreateTextBox("txtDynamic" + index);
}
private void CreateTextBox(string Id)
{
TextBox txt = new TextBox();
txt.ID = Id;
try
{
pn1TextBoxes.Controls.Add(txt);
}
catch (Exception e )
{
Response.Write(e.ToString());
}
Literal lt = new Literal();
lt.Text = "<br/>";
try
{
pn1TextBoxes.Controls.Add(lt);
}
catch (Exception e)
{
Response.Write(e.ToString());
}
}
}
|
|
|
|
|
|
I'm just learning Asp.net Web APIs. It was smooth until it's simple application/json type headers to deal with.
But now I'm trying to submit data with Content-Type:application/x-www-urlencode , but it's been really tough to get it working.
I tried different things, right from using [FromBody] attrib to "AliasBinder" etc. But nothing seem to work.
The API is dead simple , The code looks like:
class Point
{
int x {get;set;}
int y {get;set;}
}
[httpPost]
public string getValues(Point pt_in)
{
Diagnostics.Trace.TraceInfo(pt_in.x);
//Also tried using HttpUtility.Encode/Decode to read pt_in.x
}
that's it.
When I try from postman, different combo, different errors:
"Message": "The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource."
And at times (during various trial), I get 415 unsupported media type* error
I just need a simple Asp.net Web API example, where we are able to push Data as x-www-urlencode format & read the values inside the API.
Any help please?
thanks
Sum
modified 20-Sep-18 6:02am.
|
|
|
|
|
|
Thanks will try it out. most of the things explained there, I did try. But let me verify it well and get back. thanks.
|
|
|
|
|
This is a quality of life issue I've been researching. For certain controllers I would like to add a static method or property that will contain it's absolute URL so I can make redirects a little cleaner but I cannot figure out an elegant solution.
For instance
return RedirectToRoute("Index", "Home");
return RedirectToRoute(Controllers.HomeController.DefaultRedirect); Is this possible?
I've been looking at routing but all the documentation that I find is limited to top layer functionality. Additionally, everything I find requires a RequestContext , a ControllerContext , or some other object that can only be known from within the controller during a web request.
One thing that I am not liking about MVC is having the code behind peppered with string literals all pointing to different controllers and actions. I like to be able to rename the Index controller to Index2 without having to hunt down 45 different places that reference the URL. Not to mention all of the other controllers that might have an Index action that just make it more difficult to find.
if (Object.DividedByZero == true) { Universe.Implode(); }
|
|
|
|
|
|
I did see that one during my searching but since it is called from within a controller, it doesn't really help me since I am looking for a static method in a controller that will generate a correct Url all the time. I did find a way to do it but it still isn't elegant as it does not provide the absolute Url like I would like.
[MyAuthorizationFilter]
public class HomeController : Controller
{
public static string GetDefaultRedirectUrl(RequestContext context)
{
var routeValues = new RouteValueDictionary();
routeValues.Add("area", "somearea");
routeValues.Add("controller", "Home");
routeValeus.Add("action", "Index");
var urlHelper = new UrlHelper(context);
string url = urlHelper.RouteUrl(routeValues);
}
} I'm still debugging my code due to tearing it apart and rewriting it dozen times trying to figure this out. I has worked but I have to fix other things before I can see if it works for what I intend it to do.
if (Object.DividedByZero == true) { Universe.Implode(); }
|
|
|
|
|
Controllers don't have urls, that is why you are struggling to do this.
What'a the URL for this action?
public class HomeController : Controller
{
public ActionResult Index(int? id)
{
}
}
Is it /Home/Index/1? Is it /MyUrl/Index/1/Home?
The answer is both of them.
routes.MapRoute(
name: "Test",
url: "MyUrl/{action}/{id}/{controller}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
|
|
|
|
|
I was assuming that if the application can deduce which controller and action to route an http request to when a request is received that the reverse was also possible. I guess that it isn't possible after all.
It would appear that a controller cannot know where it's located in the website hierarchy until after it's called. Since the default routing basically follows the file system and/or namespaces I thought that there might be a way provided to backtrack up the structure to get a controller's absolute URL at runtime.
Sigh, back to peppering my controller and filter code with string literals.
if (Object.DividedByZero == true) { Universe.Implode(); }
|
|
|
|
|
How to Combine simple form and grid CRUD operations in single view and also post the user entered data in single submit button clicked ?
|
|
|
|
|
Good day,
as the subject suggest i would like to ask the community or atleast point em in the right direction .. i am afraid im lost within the google walls of search engine.. in fact i have 3
listed below( and some follow up question as soon as these are answered):
1) can i implement ADFS(Active Directory Federation Service) log in to an existing asp.net website?
2) would i need to re do the website to implement it?
3) do i need to use any plug ins, or is there any direct way of doing that?
im sorry for being blunt... im a beginner in web and asp.net i only created a basic website... and our system admin ask me to connect it to our Active Directory as part of our company policy
thanks in advance!
|
|
|
|
|
how to display an Image In View..?
|
|
|
|
|
By using the <img> tag, just as you would in any HTML document:
HTML img tag[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
public IHttpActionResult Post([FromBody] product Products)
{
...
}
public IHttpActionResult Post([FromBody] List<product> Products)
{
...
}
when I used List<product> I got empty products. How to handle it?
|
|
|
|
|
Can you update your question with code where you are posting the data?
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
|
Hi Friends
I have sub level hyperlink in usercontrol page, with separate css class getting called in this user control, but not sure why the sub level hyperlink is not showing when hovering on main hyperlink. Please help, is there any changes with web.config will affect this.
@ control language="C#" autoeventwireup="true" inherits="GUI_UserControl_ImmiMenu, App_Web_aau350gx" %>
<link href="../../Includes/Styles/ImmMenu.css"rel="stylesheet" type="text/css" />
<?xml version="1.0" encoding="UTF-8"?>
<div id="navigation">
<ul class="top-level">
<li><asp:HyperLink ID="HyperLink3" runat="server">WorkPermit</asp:HyperLink>
<ul class="sub-level">
<li><asp:HyperLink ID="HyperLink13" runat="server" NavigateUrl="~/GUI/Visadept/ImmFirstLook.aspx" >Pending Cases</asp:HyperLink></li>
<li><asp:HyperLink ID="HyperLink14" runat="server" NavigateUrl="~/GUI/Visadept/WorkPermitStatus.aspx" >Status</asp:HyperLink></li>
<li><asp:HyperLink ID="HyperLink15" runat="server" NavigateUrl="~/GUI/Visadept/Reports.aspx" >Report</asp:HyperLink></li>
</ul>
</li>
</ul>
</div>
Please help, this is very urgent, Thanks in advance
Regards
Priya
|
|
|
|
|
Is this some third party menu control you are using? If yes, do you have all required CSS and JS files included in the page?
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Thanks lot for reply, no I am not using 3rd party, all the related css and js files are available, and surprisingly the same set of published code is working fine, but only in some servers I am facing this issue, I doubt this is something with web.config changes I have added, but tried to compare working version vs current version, but not helping.
|
|
|
|
|
You can perhaps check in Developer Options -> Console if there are any specific errors when you access application from those servers.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Dear Team,
I am using Azure webapps to publish my ERP software . NOw i need to publish new updates to all / more than one webapp from visual studio 2017 in single publish. Because its very difficulties to publish each updates to server one by one .
Kindly help me to create a solution to upload updates to all clients in single click
Thank you
Dominic Louis
|
|
|
|