<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[בקשת GET I POST ב ASP.NET MVC 4]]></title><description><![CDATA[<p dir="auto">היי<br />
סליחה על ההתקפה בשאלות<img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f914.png?v=9d71ebe86e6" class="not-responsive emoji emoji-android emoji--thinking_face" style="height:23px;width:auto;vertical-align:middle" title=":thinking_face:" alt="🤔" /> ...<br />
יש למשהו דוגמא לבקשות GET ו POST ע"פ <a href="http://ASP.NET" target="_blank" rel="noopener noreferrer nofollow ugc">ASP.NET</a> MVC 4<br />
בעבר השתמשתי עם גרסה אחרת ששם זה היה קצת שונה<br />
ואני מחפשת תבנית כדי לבנות עליה בקשות HTTP<br />
תודה רבה!!</p>
]]></description><link>https://tchumim.com/topic/14101/בקשת-get-i-post-ב-asp-net-mvc-4</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 17:21:48 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/14101.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Oct 2022 09:54:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Fri, 21 Oct 2022 07:54:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%9E">@<bdi>ממ</bdi></a><br />
טוב....<br />
מחקירה רצינית בגוגל הגעתי ל2 מסקנות ---<br />
א. או שזה קשור לבעיה בCORS  - זה מה שרשמתי בקונטרולר:<br />
<img src="/assets/uploads/files/1666337680489-7ebf757f-7dcf-4d6f-bee0-b8e9946dafbd-image.png" alt="7ebf757f-7dcf-4d6f-bee0-b8e9946dafbd-image.png" class=" img-fluid img-markdown" /><br />
וזה בקובץ WebApiConfig:<br />
<img src="/assets/uploads/files/1666338557657-ef104c78-6de2-411b-be9d-02f732f63c65-image.png" alt="ef104c78-6de2-411b-be9d-02f732f63c65-image.png" class=" img-fluid img-markdown" /><br />
את הקובץ WebApiConfig יצרתי לבד (העתקתי את התוכן מגוגל..) זה יכול להוות בעיה??<br />
ב. או שחסר לי משהו בהגדרות של XML כי כשאני מריצה פונקציה ספציפית זה מביא אותי לשגיאה הבאה:<br />
<img src="/assets/uploads/files/1666338809966-f7da44d4-9968-4205-8f30-1db0005a4f6d-image.png" alt="f7da44d4-9968-4205-8f30-1db0005a4f6d-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">מישהו יכול לעזור לי -- זה ממש ממש דחוף!<br />
תודה רבה!</p>
]]></description><link>https://tchumim.com/post/146120</link><guid isPermaLink="true">https://tchumim.com/post/146120</guid><dc:creator><![CDATA[ממ]]></dc:creator><pubDate>Fri, 21 Oct 2022 07:54:11 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 13:54:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/clickone">@<bdi>clickone</bdi></a><br />
הוא לא מציג לי ב SWAGGER שום פונקציה(מצורף)<br />
והקונטרולר נוצר לי לבד ניסיתי להחליף וגם עשה בעיות..<br />
<img src="/assets/uploads/files/1666274038553-c3bc78e6-4ce2-4e98-b564-4001ee980d97-image.png" alt="c3bc78e6-4ce2-4e98-b564-4001ee980d97-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://tchumim.com/post/146091</link><guid isPermaLink="true">https://tchumim.com/post/146091</guid><dc:creator><![CDATA[ממ]]></dc:creator><pubDate>Thu, 20 Oct 2022 13:54:08 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 13:44:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%9E">@<bdi>ממ</bdi></a> אתם מחזירים ActionResult<br />
בגלל שצד הלקוח הוא אנגולר, אתם יכולים להחזיר ישירות את האובייקט שאתם רוצים להחזיר.<br />
<strong>אתם משתמשים בדוגמא בהחזרה בView, שהוא בד"כ מחזיר את קובץ הcshtml שנמצא בתקיית התצוגות.</strong><br />
אני חושב שאתם לא נדרשים לזה בכלל באנגולר.<br />
אפשר או:</p>
<ol>
<li>להחזיר Json ככה:</li>
</ol>
<pre><code>return Json(newClient, JsonRequestBehavior.AllowGet);
</code></pre>
<ol start="2">
<li>לחילופין אפשר לשנות את החתימה של הפונקציה ככה:</li>
</ol>
<pre><code>        public ClientView InsertClient(ClientView newClient)
</code></pre>
<p dir="auto">ואז להחזיר תשובה:</p>
<pre><code>return ClientView;
</code></pre>
<p dir="auto">יש מצב שבזה תצטרכו לעשות לו המרה לJSON גם, אני כבר לא זוכר.</p>
<p dir="auto">למה בעצם אתם לא משתמשים בקונטרוללר מסוג ApiController?<br />
דבר נוסף, אם אפשר, במידה וקיבלתם מהשרת תגובה שלא תיכננתם לקבל, תכתבו מה קיבלתם - כי לא ברור האם חזרה תשובה או משהו אחר.</p>
]]></description><link>https://tchumim.com/post/146089</link><guid isPermaLink="true">https://tchumim.com/post/146089</guid><dc:creator><![CDATA[clickone]]></dc:creator><pubDate>Thu, 20 Oct 2022 13:44:01 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 13:24:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%9E">@<bdi>ממ</bdi></a><br />
מה שניסיתי לדוגמא לבקשת POST</p>
<pre><code>[Route("api/Home/InsertClient")]
        [HttpPost]

        public ActionResult InsertClient(ClientView newClient)
        {
            try
            {
                MyBL.InsertClient(newClient.ID, newClient.FirstName, newClient.LastName);
                return View(newClient);
            }
            catch (Exception ex)
            {
                return View();
            }
        }
</code></pre>
<p dir="auto">דוגמא לבקשת GET שניסיתי:</p>
<pre><code>[Route("api/Home/ListClients")]
        [HttpGet]
                 public List&lt;ClientView&gt; ListClients()
                 {
                     return Conversion.ConvertClientToClientView(MyBL.ListClients());
                 }
</code></pre>
]]></description><link>https://tchumim.com/post/146085</link><guid isPermaLink="true">https://tchumim.com/post/146085</guid><dc:creator><![CDATA[ממ]]></dc:creator><pubDate>Thu, 20 Oct 2022 13:24:05 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 13:19:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/clickone">@<bdi>clickone</bdi></a><br />
אוקי אז שוב לא הייתי ברורה...(כנראה שאין לי את זה <img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=9d71ebe86e6" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":(" alt="😞" /> )<br />
בקשת post שאני צריכה:<br />
אני מקבלת מהקליינט (אנגולר אצלי) אובייקט נתונים מסוג Client וצריכה להכניס את הנתונים לDB שלי.</p>
<p dir="auto">ובקשת get שאני צריכה :<br />
מקבלת מה DB שלי את כל ה Client שקיימים במערכת</p>
]]></description><link>https://tchumim.com/post/146084</link><guid isPermaLink="true">https://tchumim.com/post/146084</guid><dc:creator><![CDATA[ממ]]></dc:creator><pubDate>Thu, 20 Oct 2022 13:19:39 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 12:59:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%9E">@<bdi>ממ</bdi></a> מה סוג הנתונים שצריך לחזור מהפונקציה?<br />
JSON? XML? סתם תצוגת HTML?<br />
או לפי הבקשה להחזיר את הסוג?</p>
<p dir="auto">וגם, מה הכוונה</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%9E">@<bdi>ממ</bdi></a> כתב ב<a href="/post/146081">בקשת GET I POST ב ASP.NET MVC 4</a>:</p>
<blockquote>
<p dir="auto">אני רוצה לדעת איך לרשום תפונקציות עצמם</p>
</blockquote>
<p dir="auto">אולי יותר קל שלהתחלה תסבירו מה התוצאה שאליה תרצו להגיע, ומה ניסיתם.<br />
לדוגמא:<br />
הלקוח שולח מזהה משתמש וסיסמא, והפונקציה צריכה להחזיר בוליאני אם הוא קיםם, וזו הפונקציה שלי וכו'</p>
]]></description><link>https://tchumim.com/post/146082</link><guid isPermaLink="true">https://tchumim.com/post/146082</guid><dc:creator><![CDATA[clickone]]></dc:creator><pubDate>Thu, 20 Oct 2022 12:59:34 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 12:43:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/clickone">@<bdi>clickone</bdi></a><br />
תודה<br />
אבל תבסיס של הקונטרולר יש לי<br />
אני רוצה לדעת איך לרשום תפונקציות עצמם<br />
דוגמא למשהו שרשמתי בעבר וכאן זה לא נכון:</p>
<pre><code>[Route("api/Login/IsStudent/{id}/{password}")]
        [HttpGet]
        public StudentView IsStudent(string id, int password)
        {
            return Mapper.Map&lt;Student, StudentView&gt;( MyStudentBL.GetStudent(id, password));
        }
</code></pre>
<p dir="auto">איך אני רושמת כזה דבר אבל שמותאם לקונטרולר ולא לקונטרולר API</p>
]]></description><link>https://tchumim.com/post/146081</link><guid isPermaLink="true">https://tchumim.com/post/146081</guid><dc:creator><![CDATA[ממ]]></dc:creator><pubDate>Thu, 20 Oct 2022 12:43:57 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 12:33:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%9E">@<bdi>ממ</bdi></a><br />
יצרתם קונטרולר?<br />
אתם יכולים ללחוץ קליק ימני ואז לבקש קונטרולר חדש, עם או בלי נתונים. ככה תוכלו לראות את התבנית הרגילה</p>
<p dir="auto">ניתן להשתמש עם [HttpPost] לבקשות פוסט וב [HttpGet] כאטריביוט לפני הפונקציה כדי להגדיר האם הפונקציה הזו היא GET או POST<br />
דוגמא לקונטרולר</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;

namespace MvcApplication1.Controllers
{
    public class ProductController : Controller
    {
        //
        // GET: /Products/

        public ActionResult Index()
        {
            // Add action logic here
            return View();
        }
    }
}
</code></pre>
<p dir="auto">וזה דוגמא לקונטרולר API (אפשר להשתמש ברגיל גם לבקשות API)</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace MyWebAPI.Controllers
{
    public class ValuesController : ApiController
    {
        // GET: api/values
        public IEnumerable&lt;string&gt; Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET: api/values/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/values
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/values/5
        public void Delete(int id)
        {
        }
    }
}
</code></pre>
<p dir="auto">מקורות לקוד: (כמובן ניתן לראות את הקוד גם בVS עם יצירת קונטרולר)<br />
<a href="https://learn.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/aspnet-mvc-controllers-overview-cs" target="_blank" rel="noopener noreferrer nofollow ugc">https://learn.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/aspnet-mvc-controllers-overview-cs</a></p>
<p dir="auto"><a href="https://www.tutorialsteacher.com/webapi/web-api-controller" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.tutorialsteacher.com/webapi/web-api-controller</a></p>
]]></description><link>https://tchumim.com/post/146079</link><guid isPermaLink="true">https://tchumim.com/post/146079</guid><dc:creator><![CDATA[clickone]]></dc:creator><pubDate>Thu, 20 Oct 2022 12:33:09 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 12:04:20 GMT]]></title><description><![CDATA[<p dir="auto">יש מישהו??..<img src="https://tchumim.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=9d71ebe86e6" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":disappointed:" alt="😞" /><br />
זה מאוד דחוף לי</p>
]]></description><link>https://tchumim.com/post/146077</link><guid isPermaLink="true">https://tchumim.com/post/146077</guid><dc:creator><![CDATA[ממ]]></dc:creator><pubDate>Thu, 20 Oct 2022 12:04:20 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 10:41:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid">@<bdi>dovid</bdi></a> כן</p>
]]></description><link>https://tchumim.com/post/146073</link><guid isPermaLink="true">https://tchumim.com/post/146073</guid><dc:creator><![CDATA[ממ]]></dc:creator><pubDate>Thu, 20 Oct 2022 10:41:18 GMT</pubDate></item><item><title><![CDATA[Reply to בקשת GET I POST ב ASP.NET MVC 4 on Thu, 20 Oct 2022 10:36:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%9E">@<bdi>ממ</bdi></a> כלומר מצד השרת, בקוד הC#?</p>
]]></description><link>https://tchumim.com/post/146072</link><guid isPermaLink="true">https://tchumim.com/post/146072</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Thu, 20 Oct 2022 10:36:47 GMT</pubDate></item></channel></rss>